Tango-view-refresh-red.png
Driver on

CPU frequency scaling – ArchWiki

CPU frequency scaling permits the working system to scale the CPU frequency up or down so as to save energy. CPU frequencies may be scaled robotically relying on the system load, in response to ACPI occasions, or manually by userspace applications.

CPU frequency scaling is applied within the Linux kernel, the infrastructure known as cpufreq. Since kernel 3.Four the mandatory modules are loaded robotically and the advisable ondemand governor is enabled by default. Nonetheless, userspace instruments like cpupower, acpid, Laptop computer Mode Instruments, or GUI instruments supplied on your desktop setting, should be used for superior configuration.

Userspace instruments

thermald

thermald is a Linux daemon used to stop the overheating of platforms. This daemon screens temperature and applies compensation utilizing accessible cooling strategies.

By default, it screens CPU temperature utilizing accessible CPU digital temperature sensors and maintains CPU temperature beneath management, earlier than HW takes aggressive correction motion. If there’s a pores and skin temperature sensor in thermal sysfs, then it tries to maintain pores and skin temperature beneath 45C.

The related systemd unit is thermald.service, which must be began and enabled.

i7z

i7z is an i7 (and now i3, i5, i7, i9) CPU reporting software for Linux. It may 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 help with CPU frequency scaling. The bundle isn’t required to make use of scaling, however is extremely advisable as a result of it gives helpful command-line utilities and a systemd service to vary the governor at boot.

The configuration file for cpupower is positioned in /and so on/default/cpupower. This configuration file is learn by a bash script in /usr/lib/systemd/scripts/cpupower which is activated by systemd with cpupower.service. Chances are you’ll need to allow cpupower.service to start out at boot.

cpupower-gui

cpupower-guiAUR is a graphical utility designed to help with CPU frequency scaling. The GUI is predicated on GTK and is supposed to offer the identical choices as cpupower. cpupower-gui can change the utmost/minimal CPU frequency and governor for every core. The appliance handles privilege granting by means of polkit and permits any logged-in consumer within the wheel consumer group to vary the frequency and governor.

turbostat

turbostat can show the frequency, energy consumption, idle standing and different statistics of the trendy Intel and AMD CPUs.

CPU frequency driver

Word:

  • The native CPU module is loaded robotically.
  • The intel_pstate CPU energy scaling driver is used robotically for contemporary Intel CPUs as an alternative of the opposite drivers under. This driver takes precedence over different drivers and is built-in versus being a module. This driver is at the moment robotically used for Sandy Bridge and newer CPUs. The intel_pstate could ignore the BIOS P-State settings. When you encounter an issue whereas utilizing this driver, add intel_pstate=disable to your kernel line.
  • Even P State habits talked about above may be influenced with /sys/units/system/cpu/intel_pstate, e.g. Intel Turbo Increase may be deactivated with echo 1 > /sys/units/system/cpu/intel_pstate/no_turbo as the basis consumer for holding CPU-Temperatures low.
  • Further management for contemporary Intel CPUs is out there with the Linux Thermal Daemon (accessible as thermald), which proactively controls thermal utilizing P-states, T-states, and the Intel energy clamp driver. thermald can be used for older Intel CPUs. If the most recent drivers are usually not accessible, then the daemon will revert to x86 mannequin particular registers and the Linux ‘cpufreq subsystem’ to regulate system cooling.

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

Module Description
intel_pstate This driver implements a scaling driver with an inside governor for Intel Core (Sandy Bridge and newer) processors.
acpi-cpufreq CPUFreq driver which makes use of the ACPI Processor Efficiency States. This driver additionally helps the Intel Enhanced SpeedStep (beforehand supported by the deprecated speedstep-centrino module).
speedstep-lib CPUFreq driver for Intel SpeedStep-enabled processors (largely Atoms and older Pentiums)
powernow-k8 CPUFreq driver for K8/Ok10 Athlon 64/Opteron/Phenom processors. Since Linux 3.7 ‘acpi-cpufreq’ will robotically be used for extra trendy AMD CPUs.
pcc-cpufreq This driver helps Processor Clocking Management interface by Hewlett-Packard and Microsoft Company which is beneficial on some ProLiant servers.
p4-clockmod CPUFreq driver for Intel Pentium 4/Xeon/Celeron processors which lowers the CPU temperature by skipping clocks. (You most likely need to use a SpeedStep driver as an alternative.)

To see a full record of obtainable modules, run:

$ ls /usr/lib/modules/$(uname -r)/kernel/drivers/cpufreq/

Load the suitable module (see Kernel modules for particulars). As soon as the suitable cpufreq driver is loaded, detailed details about the CPU(s) may be displayed by operating

$ cpupower frequency-info

Setting most and minimal frequencies

In some circumstances, it might be essential to manually set most and minimal frequencies.

To set the utmost clock frequency (clock_freq is a clock frequency with models: GHz, MHz):

# cpupower frequency-set -u clock_freq

To set the minimal clock frequency:

# cpupower frequency-set -d clock_freq

To set the CPU to run at a specified frequency:

# cpupower frequency-set -f clock_freq
Word:

  • To regulate for less than a single CPU core, append -c core_number.
  • The governor, most and minimal frequencies may be set in /and so on/default/cpupower.

Alternatively, you’ll be able to set the frequency manually:

# echo worth > /sys/units/system/cpu/cpu*/cpufreq/scaling_max_freq

The accessible values may be present in /sys/units/system/cpu/cpu*/cpufreq/scaling_available_frequencies or related. [1]

Disabling Turbo Increase

intel_pstate

# echo 1 > /sys/units/system/cpu/intel_pstate/no_turbo

acpi-cpufreq

# echo 0 > /sys/units/system/cpu/cpufreq/enhance

x86_energy_perf_policy

With x86_energy_perf_policy:

# x86_energy_perf_policy --turbo-enable 0

The modifications is momentary.

Scaling governors

Governors (see desk under) are energy schemes for the CPU. Just one could also be energetic at a time. For particulars, see the kernel documentation within the kernel supply.

Governor Description
efficiency Run the CPU on the most frequency.
powersave Run the CPU on the minimal frequency.
userspace Run the CPU at consumer specified frequencies.
ondemand Scales the frequency dynamically in keeping with present load. Jumps to the best frequency after which presumably again off because the idle time will increase.
conservative Scales the frequency dynamically in keeping with present load. Scales the frequency extra progressively than ondemand.
schedutil Scheduler-driven CPU frequency choice [2], [3].

Relying on the scaling driver, one among these governors will likely be loaded by default:

  • ondemand for AMD and older Intel CPU.
  • powersave for Intel CPUs utilizing the intel_pstate driver (Sandy Bridge and newer).

Warning: Use CPU monitoring instruments (for temperatures, voltage, and so on.) when altering the default governor.

To activate a specific governor, run:

# cpupower frequency-set -g governor
Word:

  • To regulate for less than a single CPU core, append -c core_number to the command above.
  • Activating a governor requires that particular kernel module (named cpufreq_governor) is loaded. As of kernel 3.4, these modules are loaded robotically.

Alternatively, you’ll be able to activate a governor on each accessible CPU manually:

# echo governor > /sys/units/system/cpu/cpu*/cpufreq/scaling_governor

the place governor is the title of the governor, talked about within the above desk, that you just need to activate.

Tip: To observe cpu velocity in actual time, run:

$ watch grep "cpu MHz" /proc/cpuinfo

Tuning the ondemand governor

See the kernel documentation for particulars.

Switching threshold

To set the edge for stepping as much as one other frequency:

# echo -n p.c > /sys/units/system/cpu/cpufreq//up_threshold

To set the edge for stepping down to a different frequency:

# echo -n p.c > /sys/units/system/cpu/cpufreq//down_threshold

Sampling charge

The sampling charge determines how incessantly the governor checks to tune the CPU. sampling_down_factor is a tunable that multiplies the sampling charge when the CPU is at its highest clock frequency thereby delaying load analysis and bettering efficiency. Allowed values for sampling_down_factor are 1 to 100000. This tunable has no impact on habits at decrease CPU frequencies/hundreds.

To learn the worth (default = 1), run:

$ cat /sys/units/system/cpu/cpufreq/ondemand/sampling_down_factor

To set the worth, run:

# echo -n worth > /sys/units/system/cpu/cpufreq/ondemand/sampling_down_factor

Make modifications everlasting

To have the specified scaling enabled at boot, kernel module choices and systemd-tmpfiles are common strategies.

For instance, altering the up_threshold to 10:

/and so on/tmpfiles.d/ondemand.conf
w- /sys/units/system/cpu/cpufreq/ondemand/up_threshold - - - - 10

Nonetheless, as famous in systemd-tmpfiles, in some circumstances race situations could exist and one can use udev to keep away from them.

For instance, to set the scaling governor of the CPU core 0 to efficiency whereas the scaling driver is acpi_cpufreq, create the next udev rule:

/and so on/udev/guidelines.d/50-scaling-governor.guidelines
SUBSYSTEM=="module", ACTION=="add", KERNEL=="acpi_cpufreq", RUN+="/bin/sh -c 'echo efficiency > /sys/units/system/cpu/cpufreq/policy0/scaling_governor'"

To have the rule already utilized within the initramfs, comply with the instance at udev#Debug output.

Tip:

  • Since Linux 5.9, it’s attainable to set the cpufreq.default_governor kernel possibility.
  • Alternatively, configure the cpupower utility and allow its systemd service.

Management Intel CPUs vitality efficiency coverage

With x86_energy_perf_policy:

Allow {Hardware} P-States:

# x86_energy_perf_policy -H 1
# x86_energy_perf_policy -U 1

Set “default” coverage:

# x86_energy_perf_policy default

Set “efficiency” coverage:

# x86_energy_perf_policy efficiency

Set “balance-performance” coverage:

# x86_energy_perf_policy balance-performance

Set “balance-power” coverage:

# x86_energy_perf_policy balance-power

Set “energy” coverage:

# x86_energy_perf_policy energy

The modifications is momentary.

CPU idle driver

Word:

  • The intel_idle CPU idle driver is used robotically for contemporary Intel CPUs as an alternative of the acpi_idle driver. This driver is at the moment robotically used for Sandy Bridge and newer CPUs. The intel_idle could ignore the BIOS C-State settings. When you encounter an issue whereas utilizing this driver, add intel_idle.max_cstate=0 to your kernel line.

Interplay with ACPI occasions

Customers could configure scaling governors to change robotically primarily based on totally different ACPI occasions similar to connecting the AC adapter or closing a laptop computer lid. A fast instance is given under, nonetheless it might be price studying full article on acpid.

Occasions are outlined in /and so on/acpi/handler.sh. If the acpid bundle is put in, the file ought to exist already and be executable. For instance, to vary the scaling governor from efficiency to conservative when the AC adapter is disconnected and alter it again if reconnected:

/and so on/acpi/handler.sh
[...]

ac_adapter)
    case "$2" in
        AC*)
            case "$4" in
                00000000)
                    echo "conservative" >/sys/units/system/cpu/cpu0/cpufreq/scaling_governor    
                    echo -n $minspeed >$setspeed
                    #/and so on/laptop-mode/laptop-mode begin
                ;;
                00000001)
                    echo "efficiency" >/sys/units/system/cpu/cpu0/cpufreq/scaling_governor
                    echo -n $maxspeed >$setspeed
                    #/and so on/laptop-mode/laptop-mode cease
                ;;
            esac
        ;;
        *) logger "ACPI motion undefined: $2" ;;
    esac
;;

[...]

Privilege granting beneath GNOME

Tango-view-refresh-red.pngThis text or part is old-fashioned.Tango-view-refresh-red.png

Word: systemd launched logind which handles consolekit and policykit actions. The next code under doesn’t work. With logind, merely edit within the file /usr/share/polkit-1/actions/org.gnome.cpufreqselector.coverage the components in keeping with your wants and the polkit handbook [4].

GNOME has a pleasant applet to vary the governor on the fly. To make use of it with out the necessity to enter the basis password, merely create following file:

/var/lib/polkit-1/localauthority/50-local.d/org.gnome.cpufreqselector.pkla
[org.gnome.cpufreqselector]
Id=unix-user:consumer
Motion=org.gnome.cpufreqselector
ResultAny=no
ResultInactive=no
ResultActive=sure

The place the phrase consumer is changed with the username of curiosity.

The desktop-privilegesAUR bundle within the AUR comprises an analogous .pkla file for authorizing all customers of the energy consumer group to vary the governor.

Troubleshooting

Tango-inaccurate.pngThe factual accuracy of this text or part is disputed.Tango-inaccurate.png

Purpose: Unverifiable and obscure statements, a lot of “some”s and “possibly”s. Troubleshooting gadgets want to deal with concrete issues. (Talk about in Discuss:CPU frequency scaling#)
  • Some functions, like ntop, don’t reply effectively to computerized frequency scaling. Within the case of ntop it may end up in segmentation faults and plenty of misplaced data as even the on-demand governor can’t change the frequency shortly sufficient when a number of packets immediately arrive on the monitored community interface that can’t be dealt with by the present processor velocity.
  • Some CPU’s could endure from poor efficiency with the default settings of the on-demand governor (e.g. flash movies not enjoying easily or stuttering window animations). As a substitute of utterly disabling frequency scaling to resolve these points, the aggressiveness of frequency scaling may be elevated by decreasing the up_threshold sysctl variable for every CPU. See the right way to change the on-demand governor’s threshold.
  • Typically the on-demand governor could not throttle to the utmost frequency however one step under. This may be solved by setting max_freq worth barely larger than the actual most. For instance, if frequency vary of the CPU is from 2.00 GHz to three.00 GHz, setting max_freq to three.01 GHz may be a good suggestion.
  • Some combos of ALSA drivers and sound chips could trigger audio skipping because the governor modifications between frequencies, switching again to a non-changing governor appears to cease the audio skipping.

BIOS frequency limitation

Some CPU/BIOS configurations could have difficulties to scale to the utmost frequency or scale to larger frequencies in any respect. That is almost certainly attributable to BIOS occasions telling the OS to restrict the frequency leading to /sys/units/system/cpu/cpu0/cpufreq/bios_limit set to a decrease worth.

Both you simply made a selected Setting within the BIOS Setup Utility, (Frequency, Thermal Administration, and so on.) you’ll be able to blame a buggy/outdated BIOS or the BIOS may need a severe motive for throttling the CPU on it is personal.

Causes like that may be (assuming your machine’s a pocket book) that the battery is eliminated (or close to loss of life) so that you’re on AC-power solely. On this case a weak AC-source may not provide sufficient electrical energy to satisfy excessive peak calls for by the general system and as there isn’t a battery to help this might result in knowledge loss, knowledge corruption or in worst case even {hardware} harm!

Not all BIOS’es restrict the CPU-Frequency on this case, however for instance most IBM/Lenovo Thinkpads do. Consult with thinkwiki for extra thinkpad associated information on this subject.

When you checked there’s not simply an odd BIOS setting and you understand what you are doing you can also make the Kernel ignore these BIOS-limitations.

Warning: Be sure to learn and understood the part above. CPU frequency limitation is a security characteristic of your BIOS and you shouldn’t have to work round it.

A particular parameter needs to be handed to the processor module.

For making an attempt this briefly change the worth in /sys/module/processor/parameters/ignore_ppc from 0 to 1.

For setting it completely Kernel modules#Setting module choices describes alternate options. For instance, you’ll be able to add processor.ignore_ppc=1 to your kernel boot line, or create

/and so on/modprobe.d/ignore_ppc.conf
# If the frequency of your machine will get wrongly restricted by BIOS, this could assist
choices processor ignore_ppc=1

See additionally

Leave a Reply

Your email address will not be published. Required fields are marked *