Difference between revisions of "CPU frequency scaling"

From ArchWiki
Jump to: navigation, search
(add Turkish interlanguage link)
m (CPU frequency driver: made the table sortable, to help compare with the default ls sorting returned by ls command below to list all available modules)
 
(220 intermediate revisions by 64 users not shown)
Line 1: Line 1:
 
[[Category:Power management]]
 
[[Category:Power management]]
 
[[Category:CPU]]
 
[[Category:CPU]]
[[Category:Daemons and system services]]
+
[[ar:CPU frequency scaling]]
[[tr:Işlemci_frekansını_ölçekleme]]
+
[[cs:CPU frequency scaling]]
{{i18n|CPU Frequency Scaling}}
 
 
[[de:Cpufrequtils]]
 
[[de:Cpufrequtils]]
 +
[[el:CPU frequency scaling]]
 +
[[es:CPU frequency scaling]]
 
[[fr:Cpufreq]]
 
[[fr:Cpufreq]]
{{Article summary start}}
+
[[it:CPU frequency scaling]]
{{Article summary text|An overview of the popular userspace tools for the kernel [http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufreq.html CPUfreq] subsystem.}}
+
[[ja:CPU 周波数スケーリング]]
{{Article summary heading|Related}}
+
[[pt:CPU frequency scaling]]
{{Article summary wiki|Laptop Mode Tools|Laptop_Mode_Tools}}
+
[[ru:CPU frequency scaling]]
{{Article summary wiki|pm-utils}}
+
[[sk:CPU frequency scaling]]
{{Article summary wiki|PHC}}
+
[[tr:Işlemci frekansını ölçekleme]]
{{Article summary end}}
+
[[zh-hans:CPU frequency scaling]]
 +
{{Related articles start}}
 +
{{Related|Power saving}}
 +
{{Related|Laptop Mode Tools}}
 +
{{Related|pm-utils}}
 +
{{Related|PHC}}
 +
{{Related articles end}}
  
cpufreq refers to the kernel infrastructure that implements CPU frequency scaling. This technology enables the operating system to scale the CPU speed 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 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.
  
At a minimum, the needed kernel modules have to be loaded and then a governor has to be set. More advanced configurations might include some combination of [[#cpufrequtils]], [[acpid]], [[laptop-mode-tools]], and GUI tools provided for your desktop environment.  
+
CPU frequency scaling is implemented in the Linux kernel, the infrastructure is called ''cpufreq''. Since kernel 3.4 the necessary modules are loaded automatically and the recommended [[#Scaling governors|ondemand governor]] is enabled by default. However, userspace tools like [[#cpupower|cpupower]], [[acpid]], [[Laptop Mode Tools]], or GUI tools provided for your desktop environment, may still be used for advanced configuration.
  
==cpufrequtils==
+
== Userspace tools ==
{{Pkg|cpufrequtils}} 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 daemon script to set the governor at boot (see [[#Daemon]] below).
 
  
The {{Pkg|cpufrequtils}} package is available in the [[Official Repositories|official repositories]].
+
=== thermald ===
  
==cpupower==
+
{{Pkg|thermald}} is a Linux daemon used to prevent the overheating of platforms. This daemon monitors temperature and applies compensation using available cooling methods.
  
{{Pkg|cpupower}} is based on cpufrequtils and it extends some features. The configuration is pretty much the same as with cpufrequtils. More information on: http://lwn.net/Articles/433002/
+
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.
  
{{Tip|Make sure you edit {{ic|/etc/conf.d/cpupower}} and set the governor/frequencies you desire before starting cpupower daemon}}
+
=== i7z ===
 +
{{Pkg|i7z}} is an i7 (and now i3, i5) CPU reporting tool for Linux. It can be launched from a Terminal with the command {{ic|i7z}} or as GUI with {{ic|i7z-gui}}.
  
==Configuration==
+
=== cpupower ===
Configuring CPU scaling is a 3-part process:
 
# Load appropriate CPU frequency driver
 
# Load desired scaling governor(s)
 
# Select a method to manage switching and tuning governor(s):
 
#* manually via {{ic|/sys}} interface or {{ic|cpufreq-set}} (from {{Pkg|cpufrequtils}}),
 
#* the cpufrequtils [[#Daemon]],
 
#* [[Laptop Mode Tools]],
 
#* [[acpid]] events,
 
#* desktop enviroment tools/applets,
 
#* or some combination of the above.
 
  
=== CPU frequency driver ===
+
{{Pkg|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.
In order for frequency scaling to work properly, the operating system must first know the limits of the CPU(s).  To accomplish this, a kernel module is loaded that can read and manage the specifications of the CPU(s).  Note that these modules may need related features enabled in BIOS which may be labeled as: ''Speedstep'', ''Cool and Quiet'', ''PowerNow!'', or ''ACPI''.
 
  
If you have a 64-bit processor, you will very likely want either '''{{ic|acpi-cpufreq}}''' for Intel processors or '''{{ic|powernow-k8}}''' for AMD K8/K10 processors (Athlon 64, Opteron, and Phenom). These modules are built for both 32 and 64-bit kernels so even if you run a 32-bit kernel on your 64-bit hardware they are probably still the ones you want.
+
The configuration file for ''cpupower'' is located in {{ic|/etc/default/cpupower}}. This configuration file is read by a bash script in {{ic|/usr/lib/systemd/scripts/cpupower}} which is activated by ''systemd'' with {{ic|cpupower.service}}. You may want to enable {{ic|cpupower.service}} to start at boot.
  
To see a full list of available drivers, run the following:
+
== CPU frequency driver ==
  
$ ls /lib/modules/$(uname -r)/kernel/drivers/cpufreq/
+
{{Note|
 +
* The native CPU module is loaded automatically.
 +
* The {{ic|pstate}} power scaling driver is used automatically for modern Intel CPUs instead of the other drivers below. This driver takes priority over other drivers and is built-in as opposed to being a module. This driver is currently automatically used for Sandy Bridge and newer CPUs. If you encounter a problem while using this driver, add {{ic|intel_pstate=disable}} to your kernel line. You can use the same user space utilities with this driver, '''but cannot control it'''.
 +
* Even P State behavior mentioned above can be influenced with {{ic|/sys/devices/system/cpu/intel_pstate}}, e.g. Intel Turbo Boost can be deactivated with {{ic|# echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo}} for keeping CPU-Temperatures low.
 +
* Additional control for modern Intel CPUs is available with the [https://01.org/linux-thermal-daemon Linux Thermal Daemon] (available as {{Pkg|thermald}}), which proactively controls thermal using P-states, T-states, and the Intel power clamp driver. thermald can also be used for older Intel CPUs. If the latest drivers are not available, then the daemon will revert to x86 model specific registers and the Linux ‘cpufreq subsystem’ to control system cooling.
 +
}}
  
The following table is a partial list of available frequency drivers (Adapted from kernel source file {{ic|<kernel source>/arch/x86/kernel/cpu/cpufreq/Kconfig}}).
+
''cpupower'' requires modules to know the limits of the native CPU:
{| border="1"
+
 
 +
{| class="wikitable sortable"
 
!Module!!Description
 
!Module!!Description
 
|-
 
|-
| acpi-cpufreq || CPUFreq driver which utilizes the ACPI Processor Performance States. This driver also supports Intel Enhanced Speedstep (previously supported by the deprecated speedstep-centrino module).
+
| intel_pstate || This driver implements a scaling driver with an internal governor for Intel Core (Sandy Bridge and newer) processors.
 
|-
 
|-
| speedstep-ich || CPUFreq driver for certain mobile Intel Pentium III (Coppermine), all mobile Intel Pentium III-M (Tualatin) and all mobile Intel Pentium 4 P4-M on systems which have an Intel ICH2, ICH3 or ICH4 southbridge.
+
| 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-smi || CPUFreq driver for certain mobile Intel Pentium III (Coppermine), all mobile Intel Pentium III-M (Tualatin) on systems which have an Intel 440BX/ZX/MX southbridge.
+
| speedstep-lib || CPUFreq driver for Intel SpeedStep-enabled processors (mostly Atoms and older Pentiums (< 3))  
 
|-
 
|-
| powernow-k8  || CPUFreq driver for K8/K10 Athlon64/Opteron/Phenom processors.
+
| 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 CPUs from this family.
 
|-
 
|-
| powernow-k7   || CPUFreq driver for mobile AMD K7 mobile processors.  
+
| pcc-cpufreq   || This driver supports Processor Clocking Control interface by Hewlett-Packard and Microsoft Corporation which is useful on some ProLiant servers.
 
|-
 
|-
| cpufreq-nforce2 || CPUFreq driver for FSB changing on nVidia nForce2 platforms. (AMD K7, Socket A)
+
| 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.)
|-
 
| 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.  When enabled it will lower CPU temperature by skipping clocks.<br>You probably want to use a Speedstep driver instead.
 
 
|}
 
|}
<br>
 
To load the CPU frequency driver manually:
 
# modprobe acpi-cpufreq
 
Note that if you attempt to load the wrong module you will get get an error such as
 
FATAL: Error inserting acpi_cpufreq ([...]/acpi-cpufreq.ko): No such device
 
  
Once the appropriate cpufreq driver is loaded, detailed information about the CPU(s) can be displayed by running:
+
To see a full list of available modules, run:
{{hc
 
|$ cpufreq-info
 
|<nowiki>
 
analyzing CPU 0:
 
  driver: acpi-cpufreq
 
  CPUs which need to switch frequency at the same time: 0 1
 
  hardware limits: 1000 MHz - 2.00 GHz
 
  available frequency steps: 2.00 GHz, 1.67 GHz, 1.33 GHz, 1000 MHz
 
  available cpufreq governors: ondemand, performance
 
  current policy: frequency should be within 1000 MHz and 2.00 GHz.
 
                  The governor "performance" may decide which speed to use
 
                  within this range.
 
  current CPU frequency is 2.00 GHz.
 
analyzing CPU 1:
 
  driver: acpi-cpufreq
 
  CPUs which need to switch frequency at the same time: 0 1
 
  hardware limits: 1000 MHz - 2.00 GHz
 
  available frequency steps: 2.00 GHz, 1.67 GHz, 1.33 GHz, 1000 MHz
 
  available cpufreq governors: ondemand, performance
 
  current policy: frequency should be within 1000 MHz and 2.00 GHz.
 
                  The governor "performance" may decide which speed to use
 
                  within this range.
 
  current CPU frequency is 2.00 GHz.
 
</nowiki>}}
 
  
To load the driver automatically at startup, add the appropriate driver to the {{ic|MODULES}} array in {{ic|/etc/rc.conf}}.  For example:
+
$ ls /usr/lib/modules/$(uname -r)/kernel/drivers/cpufreq/
MODULES=('''acpi-cpufreq''')
 
  
=== Scaling governors ===
+
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
  
Governors can be thought of as pre-configured power schemes for the CPU. Some of the governors must be loaded as kernel modules in order to be seen by user space programs. One may load as many governors as desired (only one will be active on a CPU at any given time).
+
$ cpupower frequency-info
  
Available governors:
+
=== Setting maximum and minimum frequencies ===
  
;{{ic|cpufreq_ondemand}} ''(default and recommended)'': Dynamically switches between the CPU(s) available clock speeds based on system load
+
In rare cases, it may be necessary to manually set maximum and minimum frequencies.
;{{ic|cpufreq_performance}}: The performance governor runs the CPU(s) at maximum clock speed
 
;{{ic|cpufreq_conservative}}: Similar to {{ic|ondemand}}, but the CPU(s) clock speed switches gradually through all its available frequencies based on system load
 
;{{ic|cpufreq_powersave}}: Runs the CPU(s) at minimum speed
 
;{{ic|cpufreq_userspace}}: Manually configured clock speeds by user
 
  
For Desktops and most systems, the ondemand governor can provide the best compromise between heat emission, power consumption, performance, and manageability. Since it is the default and built into the kernel, loading the CPU frequency driver should be sufficient to activate it.
+
To set the maximum clock frequency (''clock_freq'' is a clock frequency with units: GHz, MHz):
For Laptops or other mobile systems, the conservative governor can possibly provide significant savings in power consumption.
 
  
The governors {{ic|ondemand}} and {{ic|performance}} are built into the kernel and do not need to be loaded as modules. If you want to use one of the other governors, you have to load them with {{ic|modprobe}}. For example:
+
  # cpupower frequency-set -u ''clock_freq''
  # modprobe cpufreq_powersave
 
# modprobe cpufreq_userspace
 
  
Or, add the desired governor(s) to the MODULES array in {{ic|/etc/rc.conf}} and reboot.
+
To set the minimum clock frequency:
MODULES=(acpi-cpufreq '''cpufreq_powersave''' '''cpufreq_userspace''')
 
  
To see which governors have been loaded:
+
  # cpupower frequency-set -d ''clock_freq''
  # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
 
  
To see which frequencies are supported:
+
To set the CPU to run at a specified frequency:
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
 
  
Manually set the governor by running the {{ic|cpufreq-set}} command (as root). For example:
+
  # cpupower frequency-set -f ''clock_freq''
  # cpufreq-set -c 0 -g ondemand
 
  
Note that the previous command only sets the governor for the ''first'' processor!  Multicore or multiprocessor systems require the {{ic|-c}} flag to set the governor for a specific core and to repeat for each remaining. Numbering starts from 0 not 1!
+
{{Note|
 +
* To adjust for only a single CPU core, append {{ic|-c ''core_number''}}.
 +
* The governor, maximum and minimum frequencies can be set in {{ic|/etc/default/cpupower}}.
 +
}}
  
For a quad core chip:
+
== Scaling governors ==
# for i in 0 1 2 3; do cpufreq-set -c $i -g ondemand; done
 
  
For a dual core chip:
+
Governors (see table below) are power schemes for the CPU. Only one may be active at a time. For details, see the [https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt kernel documentation] in the kernel source.
# for i in 0 1; do cpufreq-set -c $i -g ondemand; done
 
 
Or use {{ic|-r}} flag to set governor for all related cores
 
# cpufreq-set -r -g ondemand
 
  
{{Note|These settings will not be preserved after a reboot/shutdown. See the [[#Daemon]] section below for configuring cpufreq governors at boot.}}
+
{| class="wikitable"
 +
! Governor !! Description
 +
|-
 +
| performance  || Run the CPU at the maximum frequency.
 +
|-
 +
| powersave    || Run the CPU at the minimum frequency.
 +
|-
 +
| userspace    || Run the CPU at user specified frequencies.
 +
|-
 +
| ondemand    || Scales the frequency dynamically according to current load. Jumps to the highest frequency and then possibly back off as the idle time increases.
 +
|-
 +
| conservative || Scales the frequency dynamically according to current load. Scales the frequency more gradually than ondemand.
 +
|-
 +
| schedutil    || Scheduler-driven CPU frequency selection [http://lwn.net/Articles/682391/], [https://lkml.org/lkml/2016/3/17/420].
 +
|}
  
Additional options such as upper and lower frequency bounds used by the governor can optionally be set by using the {{ic|-u}} and {{ic|-d}} options.  A processors valid frequencies can be seen by calling cpufreq-info.  For example, to set the second core's upper frequency bound as 2.00GHz and its lower bound as 1.00 GHz:
+
Depending on the scaling driver, one of these governors will be loaded by default:
# cpufreq-set -c 1 -g ondemand -u 2.00Ghz -d 1.00Ghz
+
* {{ic|ondemand}} for AMD and older Intel CPU.
 +
* {{ic|powersave}} for Intel CPUs using the {{ic|intel_pstate}} driver (Sandy Bridge and newer).
  
To manually set a processor to a specific frequency the userspace governor is used. For example, to set core 0 to 2.50Ghz and core 1 to 800Mhz:
+
{{Note|The {{ic|intel_pstate}} driver supports only the performance and powersave governors, but they both provide dynamic scaling. The performance governor [http://www.phoronix.com/scan.php?page&#61;news_item&px&#61;MTM3NDQ should give better power saving functionality than the old ondemand governor].}}
# cpufreq-set -c 0 -g userspace -f 2.50Ghz
 
# cpufreq-set -c 1 -g userspace -f 800Mhz
 
  
Run {{ic|cpufreq-set --help}} or {{ic|man cpufreq-set}} for more information.
+
{{Warning|Use CPU monitoring tools (for temperatures, voltage, etc.) when changing the default governor.}}  
  
For those who would like a GUI for setting governors or frequency there is [[trayfreq]], a GTK+ application that sits in the system tray.
+
To activate a particular governor, run:
  
The monitoring of CPU clock in real-time is accomplished by running:
+
  # cpupower frequency-set -g ''governor''
$ watch grep \"cpu MHz\" /proc/cpuinfo
 
or (as root, so not nearly as useful)
 
  # watch -n.5 cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
 
or
 
# watch -n.5 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
 
  
====Improving on-demand performance====
+
{{Note|
 +
* To adjust for only a single CPU core, append {{ic|-c ''core_number''}} to the command above.
 +
* Activating a governor requires that specific [[kernel module]] (named {{ic|cpufreq_''governor''}}) is loaded. As of kernel 3.4, these modules are loaded automatically.
 +
}}
  
With the out-of-the-box configuration, the ondemand governor will result in a slight but measurable and noticeable loss of performance. It will not clock up the CPU when it is at lower than 95% usage, and will sample the usage at the fastest possible frequency when at full clock speeds in order to clock back down as soon as possible.
+
Alternatively, you can activate a governor on every available CPU manually:
 +
# echo ''governor'' | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null
  
Tuning the governor for your needs can reduce the performance loss to the point where it is negligible/non-existent if you are willing to lose a lot of the power savings. If you just want to save power while idle, lowering the up_threshold to 11% and raising the sample_down_factor by an order of magnitude can accomplish this.
+
{{Tip|To monitor cpu speed in real time, run:
 +
$ watch grep \"cpu MHz\" /proc/cpuinfo
 +
}}
  
Tunables are available in {{ic|/sys/devices/system/cpu/cpufreq/ondemand/}} once the governor is loaded and selected and can be preserved at reboot using {{ic|/etc/rc.local}}.
+
=== Tuning the ondemand governor ===
  
Starting the cpufreq daemon in the background (i.e. with an {{ic|@}} in {{ic|/etc/rc.conf}}) will likely cause {{ic|/etc/rc.local}} to be processed before the cpufreq daemon has a chance to change the governor. Make sure that the cpufreq daemon script will have finished running before the tunables are set. Example:
+
See the [https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt kernel documentation] for details.
  
{{hc|/etc/rc.local|(sleep 10 && echo -n 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold) &}}
+
==== Switching threshold ====
  
=====Changing the on-demand governor's threshold=====
+
To set the threshold for stepping up to another frequency:
To change when the {{ic|ondemand}} governor switches to a higher multiplier, one can manipulate {{ic|/sys/devices/system/cpu/cpufreq/ondemand/up_threshold}}. Determine the current setting by issuing the following command as root:
 
# cat /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
 
  
The value returned should be {{ic|95}}, the default setting as of kernel version 3.0. This means that the {{ic|ondemand}} governor currently increases the clock rate if a core reaches 95% utilization. This can be changed, for example:
+
# echo -n ''percent'' > /sys/devices/system/cpu/cpufreq/<governor>/up_threshold
  
# echo -n 15 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
+
To set the threshold for stepping down to another frequency:
  
=====On-demand governor sampling_down_factor=====
+
# echo -n ''percent'' > /sys/devices/system/cpu/cpufreq/<governor>/down_threshold
{{ic|sampling_down_factor}} is another global ondemand global tunable.
 
  
Having {{ic|sampling_down_factor}} set to {{ic|1}} makes no changes from existing behavior, but having {{ic|sampling_down_factor}} set to a value greater than 1 (e.g. 100) causes it to act as a multiplier for the scheduling interval for re-evaluating load when the CPU is at its highest clock frequency due to high load. This improves performance by reducing the overhead of load evaluation and helping the CPU stay at its highest clock frequency when it is truly busy, rather than shifting back and forth in speed. This tunable has no effect on behavior at lower frequencies/lower CPU loads.
+
==== Sampling rate ====
  
Read the value (default: 1):
+
The sampling rate determines how frequently the governor checks to tune the CPU. {{ic|sampling_down_factor}} is a tunable that multiplies the sampling rate when the CPU is at its highest clock frequency thereby delaying load evaluation and improving performance. Allowed values for {{ic|sampling_down_factor}} are 1 to 100000. This tunable has no effect on behavior at lower CPU frequencies/loads.
  # cat /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
 
  
Set the value:
+
To read the value (default = 1), run:
# echo -n 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
 
  
====Tuning conservative governor====
+
$ cat /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
  
While the conservative governor switches smoothly and utilizes all of the available frequencies, users may want to tune it further. Out-of-the-box it will clock the CPU up when load reaches 75% and clock down when load drops to 20%. As with the on-demand governor, decreasing the {{ic|up_threshold}} may improve performance and responsiveness.
+
To set the value, run:
  
Tunables are available in {{ic|/sys/devices/system/cpu/cpufreq/conservative/}}. Refer to the [[#Improving ondemand performance]] section for important advice regarding making this changes permanent, and potential daemon loading issues.
+
# echo -n ''value'' > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
  
=====Changing the conservative governor's thresholds=====
+
==== Make changes permanent ====
Determine the current {{ic|up_threshold}} setting by issuing the following command as root:
 
# cat /sys/devices/system/cpu/cpufreq/conservative/up_threshold
 
  
The value returned should be {{ic|75}}, the default setting as of kernel version 3.0. This means that the {{ic|conservative}} governor currently increases the clock rate to the next highest speed if a core reaches 75% utilization. The can be changed, for example:
+
To have the desired scaling enabled at boot, [[Kernel_modules#Using_files_in_.2Fetc.2Fmodprobe.d.2F|kernel module options]] and [[systemd#Temporary files]] are regular methods. However, in some cases there might be race conditions, as noted in [[systemd#Temporary files]]. [[udev]] is doing better.
  
# echo -n 40 > /sys/devices/system/cpu/cpufreq/conservative/up_threshold
+
For example, to set the scaling governor of the CPU core {{ic|0}} to performance while the scaling driver is {{ic|acpi_cpufreq}}, create the following udev rule:
  
{{Note|The minimum value one can enter must be above the one in {{ic|down_threshold}}; entering a value under that results in the error, "bash: echo: write error: Invalid argument"}}
+
{{hc|/etc/udev/rules.d/50-scaling-governor.rules|<nowiki>
 +
SUBSYSTEM=="module", ACTION=="add", KERNEL=="acpi_cpufreq", RUN+=" /bin/sh -c ' echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor ' "
 +
</nowiki>}}
  
Similarly the {{ic|down_threshold}} value can be read and modified via {{ic|/sys/devices/system/cpu/cpufreq/conservative/down_threshold}}. The default value should be {{ic|20}} as of kernel version 3.0. This means that the {{ic|conservative}} governor decreases the clock rate to the next lowest speed if a core falls to 20% utilization, which is a sensible default.
+
To have the rule already applied in the ''initramfs'', follow the example at [[udev#Debug output]].
  
While the down sampling rate can also be adjusted for the {{ic|conservative}} governor, increasing it may only help with occasional low usage CPU spikes during high usage applications, as the {{ic|down_threshold}} is a much more direct control for down scaling which does not exist on the {{ic|ondemand}} governor.
+
== Interaction with ACPI events ==
  
Be aware that setting {{ic|down_threshold}} too close to {{ic|up_threshold}} may result in constant CPU switching, which might be something desirable for certain users and not for others. Setting {{ic|down_threshold}} or {{ic|up_threshold}} too low may result in the CPU being clocked higher than it needs sacrificing power saving for performance, and setting {{ic|up_threshold}} too high may result in decreased performance, but reduced power consumption. Experiment to find the optimal values for your system and your needs.
+
Users may configure scaling governors to switch automatically based on different ACPI events such as connecting the AC adapter or closing a laptop lid. A quick example is given below, however it may be worth reading full article on [[acpid]].
 
 
==== Interaction with ACPI events ====
 
 
 
Users may configure scaling governors to switch automatically based on different ACPI events such as connecting the AC adapter or closing a laptop lid. A quick example is given below, however it may be worth reading full article on [[acpid]].
 
  
 
Events are defined in {{ic|/etc/acpi/handler.sh}}. If the {{Pkg|acpid}} package is installed, the file should already exist and be executable. For example, to change the scaling governor from {{ic|performance}} to {{ic|conservative}} when the AC adapter is disconnected and change it back if reconnected:
 
Events are defined in {{ic|/etc/acpi/handler.sh}}. If the {{Pkg|acpid}} package is installed, the file should already exist and be executable. For example, to change the scaling governor from {{ic|performance}} to {{ic|conservative}} when the AC adapter is disconnected and change it back if reconnected:
  
{{hc
+
{{hc|/etc/acpi/handler.sh|<nowiki>
|/etc/acpi/handler.sh
 
|<nowiki>
 
 
[...]
 
[...]
  
ac_adapter)
+
ac_adapter)
    case "$2" in
+
    case "$2" in
        AC*)
+
        AC*)
            case "$4" in
+
            case "$4" in
                00000000)
+
                00000000)
                    echo "conservative" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor     
+
                    echo "conservative" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor     
                    echo -n $minspeed >$setspeed
+
                    echo -n $minspeed >$setspeed
                    #/etc/laptop-mode/laptop-mode start
+
                    #/etc/laptop-mode/laptop-mode start
                ;;
+
                ;;
                00000001)
+
                00000001)
                    echo "performance" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+
                    echo "performance" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
                    echo -n $maxspeed >$setspeed
+
                    echo -n $maxspeed >$setspeed
                    #/etc/laptop-mode/laptop-mode stop
+
                    #/etc/laptop-mode/laptop-mode stop
                ;;
+
                ;;
            esac
+
            esac
        ;;
+
        ;;
        *) logger "ACPI action undefined: $2" ;;
+
        *) logger "ACPI action undefined: $2" ;;
    esac
+
    esac
;;
+
;;
  
 
[...]
 
[...]
 
</nowiki>}}
 
</nowiki>}}
  
=== Daemon ===
+
== Privilege granting under GNOME ==
{{Pkg|cpufrequtils}} includes a daemon which allows users to set the desired scaling governor and min/max clock speeds for all processor cores at boot-time.
 
  
Before starting the daemon, edit {{ic|/etc/conf.d/cpufreq}} as root, selecting the desired governor and setting the min/max speed for your CPU(s), for example:
+
{{Out of date|See the note below.}}
  
{{hc
+
{{Note|systemd introduced logind which handles consolekit and policykit actions. The following code below does not work. With logind, simply edit in the file {{ic|/usr/share/polkit-1/actions/org.gnome.cpufreqselector.policy}} the <defaults> elements according to your needs and the polkit manual [http://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html].}}
|/etc/conf.d/cpufreq
 
|<nowiki>
 
#configuration for cpufreq control
 
  
# valid governors:
+
[[GNOME]] has a nice applet to change the governor on the fly. To use it without the need to enter the root password, simply create following file:
#  ondemand, performance, powersave,
 
#  conservative, userspace
 
governor="ondemand"
 
  
# valid suffixes: Hz, kHz (default), MHz, GHz, THz
+
{{hc|/var/lib/polkit-1/localauthority/50-local.d/org.gnome.cpufreqselector.pkla|2=
min_freq="1GHz"
+
[org.gnome.cpufreqselector]
max_freq="2GHz"
+
Identity=unix-user:''user''
</nowiki>}}
+
Action=org.gnome.cpufreqselector
 +
ResultAny=no
 +
ResultInactive=no
 +
ResultActive=yes
 +
}}
 +
 
 +
Where the word ''user'' is replaced with the username of interest.
 +
 
 +
The {{AUR|desktop-privileges}} package in the [[AUR]] contains a similar {{ic|.pkla}} file for authorizing all users of the {{ic|power}} [[group]] to change the governor.
 +
 
 +
== Troubleshooting ==
 +
 
 +
{{Accuracy|Unverifiable and vague statements, lots of "some"s and "maybe"s. Troubleshooting items need to address concrete problems.}}
 +
 
 +
* Some applications, like [[ntop]], do not respond well to automatic frequency scaling. In the case of ntop it can result in segmentation faults and lots of lost information as even the {{ic|on-demand}} governor cannot change the frequency quickly enough when a lot of packets suddenly arrive at the monitored network interface that cannot be handled by the current processor speed.
 +
 
 +
* Some CPU's may suffer from poor performance with the default settings of the {{ic|on-demand}} governor (e.g. flash videos not playing smoothly or stuttering window animations). Instead of completely disabling frequency scaling to resolve these issues, the aggressiveness of frequency scaling can be increased by lowering the ''up_threshold'' [[sysctl]] variable for each CPU. See [[#Switching_threshold|how to change the on-demand governor's threshold]].
  
{{Note|The exact min/max values of the CPU(s) can be determined by running {{ic|cpufreq-info}} after loading the CPU driver (e.g. {{ic|modprobe acpi-cpufreq}}). However, these values are ''optional''. Users may omit them entirely by deleting or commenting out the min/max_freq lines; scaling will work automatically.}}
+
* Sometimes the on-demand governor may not throttle to the maximum frequency but one step below. This can be solved by setting max_freq value slightly higher than the real maximum. For example, if frequency range of the CPU is from 2.00 GHz to 3.00 GHz, setting max_freq to 3.01 GHz can be a good idea.
  
With the appropriate configuration, start the daemon with the following command:
+
* Some combinations of [[ALSA]] drivers and sound chips may cause audio skipping as the governor changes between frequencies, switching back to a non-changing governor seems to stop the audio skipping.
# rc.d start cpufreq
 
  
To start the daemon automatically at startup, add {{ic|cpufreq}} to the {{ic|DAEMONS}} array in {{ic|/etc/rc.conf}}, for example:
+
=== BIOS frequency limitation ===
DAEMONS=(syslog-ng networkmanager @alsa @crond @cupsd '''@cpufreq''')
 
  
=== Privilege Granting Under GNOME ===
+
Some CPU/BIOS configurations may have difficulties to scale to the maximum frequency or scale to higher frequencies at all. This is most likely caused by BIOS events telling the OS to limit the frequency resulting in {{ic|/sys/devices/system/cpu/cpu0/cpufreq/bios_limit}} set to a lower value.
  
[[GNOME]] has a nice applet to change the governor on the fly. To use it without the need to enter the root password, simply create {{ic|/var/lib/polkit-1/localauthority/50-local.d/org.gnome.cpufreqselector.pkla}} and populate it with the following:
+
Either you just made a specific Setting in the BIOS Setup Utility, (Frequency, Thermal Management, etc.) you can blame a buggy/outdated BIOS or the BIOS might have a serious reason for throttling the CPU on it's own.
  
{{bc|<nowiki>[org.gnome.cpufreqselector]
+
Reasons like that can be (assuming your machine's a notebook) that the battery is removed (or near death) so you're on AC-power only. In this case a weak AC-source might not supply enough electricity to fulfill extreme peak demands by the overall system and as there is no battery to assist this could lead to data loss, data corruption or in worst case even hardware damage!
Identity=unix-user:USER
 
Action=org.gnome.cpufreqselector
 
ResultAny=no
 
ResultInactive=no
 
ResultActive=yes</nowiki>}}0
 
  
Where the word {{ic|USER}} is replaced with the username of interest.
+
Not all BIOS'es limit the CPU-Frequency in this case, but for example most IBM/Lenovo Thinkpads do. Refer to thinkwiki for more [http://www.thinkwiki.org/wiki/Problem_with_CPU_frequency_scaling thinkpad related info on this topic].
  
The {{AUR|desktop-privileges}} package in the [[Arch User Repository|AUR]] contains a similar {{ic|.pkla}} file for authorizing all users of the {{ic|power}} [[Users and Groups|group]] to change the governor.
+
If you checked there's not just an odd BIOS setting and you know what you're doing you can make the Kernel ignore these BIOS-limitations.
  
===Laptop Mode Tools===
+
{{Warning|Make sure you read and understood the section above. CPU frequency limitation is a safety feature of your BIOS and you should not need to work around it.}}
If you are already using or plan to use [[Laptop Mode Tools]] for other power saving solutions, then you may want to let it also manage CPU frequency scaling. To do so, you just have to insert the appropriate frequency driver to the {{ic|MODULES}} array in {{ic|/etc/rc.conf}} (see [[#CPU frequency driver]] above) and then go through the {{ic|/etc/laptop-mode/conf.d/cpufreq.conf}} file to define governors, frequencies and policies. You will not need to load other modules and daemons or to set up scaling governors and interaction with ACPI events. Please refer to [[Laptop Mode Tools]] for more details.
 
  
== Troubleshooting ==
+
A special parameter has to be passed to the processor module.
{{accuracy}}
 
* Some applications, like [[ntop]], do not respond well to automatic frequency scaling. In the case of ntop it can result in segmentation faults and lots of lost information as even the {{ic|on-demand}} governor cannot change the frequency quickly enough when a lot of packets suddenly arrive at the monitored network interface that cannot be handled by the current processor speed.
 
  
* Some CPU's may suffer from poor performance with the default settings of the {{ic|on-demand}} governor (e.g. flash videos not playing smoothly or stuttering window animations). Instead of completely disabling frequency scaling to resolve these issues, the aggressiveness of frequency scaling can be increased by lowering the ''up_threshold'' [[sysctl]] variable for each CPU. See [[#Changing the on-demand governor's threshold]].
+
For trying this temporarily change the value in {{ic|/sys/module/processor/parameters/ignore_ppc}} from {{ic|0}} to {{ic|1}}.
  
* Sometimes the on-demand governor may not throttle to the maximum frequency but one step below. This can be solved by setting max_freq value slightly higher than the real maximum. For example, if frequency range of the CPU is from 2.00 GHz to 3.00 GHz, setting max_freq to 3.01 GHz can be a good idea.
+
For setting it permanently [[Kernel modules#Setting module options]] describes alternatives. For example, you can add {{ic|1=processor.ignore_ppc=1}} to your kernel boot line, or create
 +
{{hc|/etc/modprobe.d/ignore_ppc.conf|2=# If the frequency of your machine gets wrongly limited by BIOS, this should help
 +
options processor ignore_ppc=1}}
  
* Some CPU/BIOS configurations may have difficulties to scale to the maximum frequencies or scale to higher frequencies at all. Sadly there is only a workaround right now. Add "processor.ignore_ppc=1" to your kernel boot line and/or edit the value in {{ic|/sys/module/processor/parameters/ignore_ppc}} from 0 to 1.
+
== See also ==
** It seems to be fixed at least since kernel 3.0, for Toshiba NB-100.
 
** But this still seems not to be true for my fresh Thinkpad X60 Setup. The 32bit Intel Core Duo T2400 is still usually fixed at 1GHz with kernel 3.2.6-2 while only with the ignore_ppc option set (as described above) it's able to scale up to 1.83GHz like expected.
 
  
* Some combinations of [[ALSA]] drivers and sound chips may cause audio skipping as the governor changes between frequencies, switching back to a non-changing governor seems to stop the audio skipping.
+
* [https://www.kernel.org/doc/Documentation/cpu-freq/index.txt Linux CPUFreq - kernel documentation]
 +
* [http://www.reddit.com/r/linux/comments/1hdogn/acpi_cpufreq_or_intel_pstates/ Comprehensive explanation of pstate]

Latest revision as of 13:55, 19 April 2017

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 and the recommended ondemand 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.

Userspace tools

thermald

thermald is a Linux daemon used to prevent the overheating of platforms. 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.

i7z

i7z is an i7 (and now i3, i5) 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.

CPU frequency driver

Note:
  • The native CPU module is loaded automatically.
  • The pstate power scaling driver is used automatically for modern Intel CPUs instead of the other drivers below. This driver takes priority over other drivers and is built-in as opposed to being a module. This driver is currently automatically used for Sandy Bridge and newer CPUs. If you encounter a problem while using this driver, add intel_pstate=disable to your kernel line. You can use the same user space utilities with this driver, but cannot control it.
  • Even P State behavior mentioned above can be influenced with /sys/devices/system/cpu/intel_pstate, e.g. Intel Turbo Boost can be deactivated with # echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo for keeping CPU-Temperatures low.
  • Additional control for modern Intel CPUs is available with the Linux Thermal Daemon (available as thermald), which proactively controls thermal using P-states, T-states, and the Intel power clamp driver. thermald can also be used for older Intel CPUs. If the latest drivers are not available, then the daemon will revert to x86 model specific registers and the Linux ‘cpufreq subsystem’ to control system cooling.

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.
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 (< 3))
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 CPUs from this family.
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:

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

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

$ cpupower frequency-info

Setting maximum and minimum frequencies

In rare 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):

# cpupower frequency-set -u clock_freq

To set the minimum clock frequency:

# cpupower frequency-set -d clock_freq

To set the CPU to run at a specified frequency:

# cpupower frequency-set -f clock_freq
Note:
  • To adjust for only a single CPU core, append -c core_number.
  • The governor, maximum and minimum frequencies can be set in /etc/default/cpupower.

Scaling governors

Governors (see table below) are power schemes for the CPU. Only one may be active at a time. For details, see the kernel documentation in the kernel source.

Governor Description
performance Run the CPU at the maximum frequency.
powersave Run the CPU at the minimum frequency.
userspace Run the CPU at user specified frequencies.
ondemand Scales the frequency dynamically according to current load. Jumps to the highest frequency and then possibly back off as the idle time increases.
conservative Scales the frequency dynamically according to current load. Scales the frequency more gradually than ondemand.
schedutil Scheduler-driven CPU frequency selection [1], [2].

Depending on the scaling driver, one of these governors will be loaded by default:

  • ondemand for AMD and older Intel CPU.
  • powersave for Intel CPUs using the intel_pstate driver (Sandy Bridge and newer).
Note: The intel_pstate driver supports only the performance and powersave governors, but they both provide dynamic scaling. The performance governor should give better power saving functionality than the old ondemand governor.
Warning: Use CPU monitoring tools (for temperatures, voltage, etc.) when changing the default governor.

To activate a particular governor, run:

# cpupower frequency-set -g governor
Note:
  • To adjust for only a single CPU core, append -c core_number to the command above.
  • Activating a governor requires that specific kernel module (named cpufreq_governor) is loaded. As of kernel 3.4, these modules are loaded automatically.

Alternatively, you can activate a governor on every available CPU manually:

# echo governor | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null
Tip: To monitor cpu speed in real time, run:
$ watch grep \"cpu MHz\" /proc/cpuinfo

Tuning the ondemand governor

See the kernel documentation for details.

Switching threshold

To set the threshold for stepping up to another frequency:

# echo -n percent > /sys/devices/system/cpu/cpufreq/<governor>/up_threshold

To set the threshold for stepping down to another frequency:

# echo -n percent > /sys/devices/system/cpu/cpufreq/<governor>/down_threshold

Sampling rate

The sampling rate determines how frequently the governor checks to tune the CPU. sampling_down_factor is a tunable that multiplies the sampling rate when the CPU is at its highest clock frequency thereby delaying load evaluation and improving performance. Allowed values for sampling_down_factor are 1 to 100000. This tunable has no effect on behavior at lower CPU frequencies/loads.

To read the value (default = 1), run:

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

To set the value, run:

# echo -n value > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor

Make changes permanent

To have the desired scaling enabled at boot, kernel module options and systemd#Temporary files are regular methods. However, in some cases there might be race conditions, as noted in systemd#Temporary files. udev is doing better.

For example, to set the scaling governor of the CPU core 0 to performance while the scaling driver is acpi_cpufreq, create the following udev rule:

/etc/udev/rules.d/50-scaling-governor.rules
SUBSYSTEM=="module", ACTION=="add", KERNEL=="acpi_cpufreq", RUN+=" /bin/sh -c ' echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor ' "

To have the rule already applied in the initramfs, follow the example at udev#Debug output.

Interaction with ACPI events

Users may configure scaling governors to switch automatically based on different ACPI events such as connecting the AC adapter or closing a laptop lid. A quick example is given below, however it may be worth reading full article on acpid.

Events are defined in /etc/acpi/handler.sh. If the acpid package is installed, the file should already exist and be executable. For example, to change the scaling governor from performance to conservative when the AC adapter is disconnected and change it back if reconnected:

/etc/acpi/handler.sh
[...]

ac_adapter)
    case "$2" in
        AC*)
            case "$4" in
                00000000)
                    echo "conservative" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor    
                    echo -n $minspeed >$setspeed
                    #/etc/laptop-mode/laptop-mode start
                ;;
                00000001)
                    echo "performance" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
                    echo -n $maxspeed >$setspeed
                    #/etc/laptop-mode/laptop-mode stop
                ;;
            esac
        ;;
        *) logger "ACPI action undefined: $2" ;;
    esac
;;

[...]

Privilege granting under GNOME

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: See the note below. (Discuss in Talk:CPU frequency scaling#)
Note: systemd introduced logind which handles consolekit and policykit actions. The following code below does not work. With logind, simply edit in the file /usr/share/polkit-1/actions/org.gnome.cpufreqselector.policy the <defaults> elements according to your needs and the polkit manual [3].

GNOME has a nice applet to change the governor on the fly. To use it without the need to enter the root password, simply create following file:

/var/lib/polkit-1/localauthority/50-local.d/org.gnome.cpufreqselector.pkla
[org.gnome.cpufreqselector]
Identity=unix-user:user
Action=org.gnome.cpufreqselector
ResultAny=no
ResultInactive=no
ResultActive=yes

Where the word user is replaced with the username of interest.

The desktop-privilegesAUR package in the AUR contains a similar .pkla file for authorizing all users of the power group to change the governor.

Troubleshooting

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Unverifiable and vague statements, lots of "some"s and "maybe"s. Troubleshooting items need to address concrete problems. (Discuss in Talk:CPU frequency scaling#)
  • Some applications, like ntop, do not respond well to automatic frequency scaling. In the case of ntop it can result in segmentation faults and lots of lost information as even the on-demand governor cannot change the frequency quickly enough when a lot of packets suddenly arrive at the monitored network interface that cannot be handled by the current processor speed.
  • Some CPU's may suffer from poor performance with the default settings of the on-demand governor (e.g. flash videos not playing smoothly or stuttering window animations). Instead of completely disabling frequency scaling to resolve these issues, the aggressiveness of frequency scaling can be increased by lowering the up_threshold sysctl variable for each CPU. See how to change the on-demand governor's threshold.
  • Sometimes the on-demand governor may not throttle to the maximum frequency but one step below. This can be solved by setting max_freq value slightly higher than the real maximum. For example, if frequency range of the CPU is from 2.00 GHz to 3.00 GHz, setting max_freq to 3.01 GHz can be a good idea.
  • Some combinations of ALSA drivers and sound chips may cause audio skipping as the governor changes between frequencies, switching back to a non-changing governor seems to stop the audio skipping.

BIOS frequency limitation

Some CPU/BIOS configurations may have difficulties to scale to the maximum frequency or scale to higher frequencies at all. This is most likely caused by BIOS events telling the OS to limit the frequency resulting in /sys/devices/system/cpu/cpu0/cpufreq/bios_limit set to a lower value.

Either you just made a specific Setting in the BIOS Setup Utility, (Frequency, Thermal Management, etc.) you can blame a buggy/outdated BIOS or the BIOS might have a serious reason for throttling the CPU on it's own.

Reasons like that can be (assuming your machine's a notebook) that the battery is removed (or near death) so you're on AC-power only. In this case a weak AC-source might not supply enough electricity to fulfill extreme peak demands by the overall system and as there is no battery to assist this could lead to data loss, data corruption or in worst case even hardware damage!

Not all BIOS'es limit the CPU-Frequency in this case, but for example most IBM/Lenovo Thinkpads do. Refer to thinkwiki for more thinkpad related info on this topic.

If you checked there's not just an odd BIOS setting and you know what you're doing you can make the Kernel ignore these BIOS-limitations.

Warning: Make sure you read and understood the section above. CPU frequency limitation is a safety feature of your BIOS and you should not need to work around it.

A special parameter has to be passed to the processor module.

For trying this temporarily change the value in /sys/module/processor/parameters/ignore_ppc from 0 to 1.

For setting it permanently Kernel modules#Setting module options describes alternatives. For example, you can add processor.ignore_ppc=1 to your kernel boot line, or create

/etc/modprobe.d/ignore_ppc.conf
# If the frequency of your machine gets wrongly limited by BIOS, this should help
options processor ignore_ppc=1

See also