brintos

brintos / linux-shallow public Read only

0
0
Text · 33.3 KiB · a21369e Raw
713 lines · plain
1.. SPDX-License-Identifier: GPL-2.02.. include:: <isonum.txt>3 4.. |intel_pstate| replace:: :doc:`intel_pstate <intel_pstate>`5 6=======================7CPU Performance Scaling8=======================9 10:Copyright: |copy| 2017 Intel Corporation11 12:Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>13 14 15The Concept of CPU Performance Scaling16======================================17 18The majority of modern processors are capable of operating in a number of19different clock frequency and voltage configurations, often referred to as20Operating Performance Points or P-states (in ACPI terminology).  As a rule,21the higher the clock frequency and the higher the voltage, the more instructions22can be retired by the CPU over a unit of time, but also the higher the clock23frequency and the higher the voltage, the more energy is consumed over a unit of24time (or the more power is drawn) by the CPU in the given P-state.  Therefore25there is a natural tradeoff between the CPU capacity (the number of instructions26that can be executed over a unit of time) and the power drawn by the CPU.27 28In some situations it is desirable or even necessary to run the program as fast29as possible and then there is no reason to use any P-states different from the30highest one (i.e. the highest-performance frequency/voltage configuration31available).  In some other cases, however, it may not be necessary to execute32instructions so quickly and maintaining the highest available CPU capacity for a33relatively long time without utilizing it entirely may be regarded as wasteful.34It also may not be physically possible to maintain maximum CPU capacity for too35long for thermal or power supply capacity reasons or similar.  To cover those36cases, there are hardware interfaces allowing CPUs to be switched between37different frequency/voltage configurations or (in the ACPI terminology) to be38put into different P-states.39 40Typically, they are used along with algorithms to estimate the required CPU41capacity, so as to decide which P-states to put the CPUs into.  Of course, since42the utilization of the system generally changes over time, that has to be done43repeatedly on a regular basis.  The activity by which this happens is referred44to as CPU performance scaling or CPU frequency scaling (because it involves45adjusting the CPU clock frequency).46 47 48CPU Performance Scaling in Linux49================================50 51The Linux kernel supports CPU performance scaling by means of the ``CPUFreq``52(CPU Frequency scaling) subsystem that consists of three layers of code: the53core, scaling governors and scaling drivers.54 55The ``CPUFreq`` core provides the common code infrastructure and user space56interfaces for all platforms that support CPU performance scaling.  It defines57the basic framework in which the other components operate.58 59Scaling governors implement algorithms to estimate the required CPU capacity.60As a rule, each governor implements one, possibly parametrized, scaling61algorithm.62 63Scaling drivers talk to the hardware.  They provide scaling governors with64information on the available P-states (or P-state ranges in some cases) and65access platform-specific hardware interfaces to change CPU P-states as requested66by scaling governors.67 68In principle, all available scaling governors can be used with every scaling69driver.  That design is based on the observation that the information used by70performance scaling algorithms for P-state selection can be represented in a71platform-independent form in the majority of cases, so it should be possible72to use the same performance scaling algorithm implemented in exactly the same73way regardless of which scaling driver is used.  Consequently, the same set of74scaling governors should be suitable for every supported platform.75 76However, that observation may not hold for performance scaling algorithms77based on information provided by the hardware itself, for example through78feedback registers, as that information is typically specific to the hardware79interface it comes from and may not be easily represented in an abstract,80platform-independent way.  For this reason, ``CPUFreq`` allows scaling drivers81to bypass the governor layer and implement their own performance scaling82algorithms.  That is done by the |intel_pstate| scaling driver.83 84 85``CPUFreq`` Policy Objects86==========================87 88In some cases the hardware interface for P-state control is shared by multiple89CPUs.  That is, for example, the same register (or set of registers) is used to90control the P-state of multiple CPUs at the same time and writing to it affects91all of those CPUs simultaneously.92 93Sets of CPUs sharing hardware P-state control interfaces are represented by94``CPUFreq`` as struct cpufreq_policy objects.  For consistency,95struct cpufreq_policy is also used when there is only one CPU in the given96set.97 98The ``CPUFreq`` core maintains a pointer to a struct cpufreq_policy object for99every CPU in the system, including CPUs that are currently offline.  If multiple100CPUs share the same hardware P-state control interface, all of the pointers101corresponding to them point to the same struct cpufreq_policy object.102 103``CPUFreq`` uses struct cpufreq_policy as its basic data type and the design104of its user space interface is based on the policy concept.105 106 107CPU Initialization108==================109 110First of all, a scaling driver has to be registered for ``CPUFreq`` to work.111It is only possible to register one scaling driver at a time, so the scaling112driver is expected to be able to handle all CPUs in the system.113 114The scaling driver may be registered before or after CPU registration.  If115CPUs are registered earlier, the driver core invokes the ``CPUFreq`` core to116take a note of all of the already registered CPUs during the registration of the117scaling driver.  In turn, if any CPUs are registered after the registration of118the scaling driver, the ``CPUFreq`` core will be invoked to take note of them119at their registration time.120 121In any case, the ``CPUFreq`` core is invoked to take note of any logical CPU it122has not seen so far as soon as it is ready to handle that CPU.  [Note that the123logical CPU may be a physical single-core processor, or a single core in a124multicore processor, or a hardware thread in a physical processor or processor125core.  In what follows "CPU" always means "logical CPU" unless explicitly stated126otherwise and the word "processor" is used to refer to the physical part127possibly including multiple logical CPUs.]128 129Once invoked, the ``CPUFreq`` core checks if the policy pointer is already set130for the given CPU and if so, it skips the policy object creation.  Otherwise,131a new policy object is created and initialized, which involves the creation of132a new policy directory in ``sysfs``, and the policy pointer corresponding to133the given CPU is set to the new policy object's address in memory.134 135Next, the scaling driver's ``->init()`` callback is invoked with the policy136pointer of the new CPU passed to it as the argument.  That callback is expected137to initialize the performance scaling hardware interface for the given CPU (or,138more precisely, for the set of CPUs sharing the hardware interface it belongs139to, represented by its policy object) and, if the policy object it has been140called for is new, to set parameters of the policy, like the minimum and maximum141frequencies supported by the hardware, the table of available frequencies (if142the set of supported P-states is not a continuous range), and the mask of CPUs143that belong to the same policy (including both online and offline CPUs).  That144mask is then used by the core to populate the policy pointers for all of the145CPUs in it.146 147The next major initialization step for a new policy object is to attach a148scaling governor to it (to begin with, that is the default scaling governor149determined by the kernel command line or configuration, but it may be changed150later via ``sysfs``).  First, a pointer to the new policy object is passed to151the governor's ``->init()`` callback which is expected to initialize all of the152data structures necessary to handle the given policy and, possibly, to add153a governor ``sysfs`` interface to it.  Next, the governor is started by154invoking its ``->start()`` callback.155 156That callback is expected to register per-CPU utilization update callbacks for157all of the online CPUs belonging to the given policy with the CPU scheduler.158The utilization update callbacks will be invoked by the CPU scheduler on159important events, like task enqueue and dequeue, on every iteration of the160scheduler tick or generally whenever the CPU utilization may change (from the161scheduler's perspective).  They are expected to carry out computations needed162to determine the P-state to use for the given policy going forward and to163invoke the scaling driver to make changes to the hardware in accordance with164the P-state selection.  The scaling driver may be invoked directly from165scheduler context or asynchronously, via a kernel thread or workqueue, depending166on the configuration and capabilities of the scaling driver and the governor.167 168Similar steps are taken for policy objects that are not new, but were "inactive"169previously, meaning that all of the CPUs belonging to them were offline.  The170only practical difference in that case is that the ``CPUFreq`` core will attempt171to use the scaling governor previously used with the policy that became172"inactive" (and is re-initialized now) instead of the default governor.173 174In turn, if a previously offline CPU is being brought back online, but some175other CPUs sharing the policy object with it are online already, there is no176need to re-initialize the policy object at all.  In that case, it only is177necessary to restart the scaling governor so that it can take the new online CPU178into account.  That is achieved by invoking the governor's ``->stop`` and179``->start()`` callbacks, in this order, for the entire policy.180 181As mentioned before, the |intel_pstate| scaling driver bypasses the scaling182governor layer of ``CPUFreq`` and provides its own P-state selection algorithms.183Consequently, if |intel_pstate| is used, scaling governors are not attached to184new policy objects.  Instead, the driver's ``->setpolicy()`` callback is invoked185to register per-CPU utilization update callbacks for each policy.  These186callbacks are invoked by the CPU scheduler in the same way as for scaling187governors, but in the |intel_pstate| case they both determine the P-state to188use and change the hardware configuration accordingly in one go from scheduler189context.190 191The policy objects created during CPU initialization and other data structures192associated with them are torn down when the scaling driver is unregistered193(which happens when the kernel module containing it is unloaded, for example) or194when the last CPU belonging to the given policy in unregistered.195 196 197Policy Interface in ``sysfs``198=============================199 200During the initialization of the kernel, the ``CPUFreq`` core creates a201``sysfs`` directory (kobject) called ``cpufreq`` under202:file:`/sys/devices/system/cpu/`.203 204That directory contains a ``policyX`` subdirectory (where ``X`` represents an205integer number) for every policy object maintained by the ``CPUFreq`` core.206Each ``policyX`` directory is pointed to by ``cpufreq`` symbolic links207under :file:`/sys/devices/system/cpu/cpuY/` (where ``Y`` represents an integer208that may be different from the one represented by ``X``) for all of the CPUs209associated with (or belonging to) the given policy.  The ``policyX`` directories210in :file:`/sys/devices/system/cpu/cpufreq` each contain policy-specific211attributes (files) to control ``CPUFreq`` behavior for the corresponding policy212objects (that is, for all of the CPUs associated with them).213 214Some of those attributes are generic.  They are created by the ``CPUFreq`` core215and their behavior generally does not depend on what scaling driver is in use216and what scaling governor is attached to the given policy.  Some scaling drivers217also add driver-specific attributes to the policy directories in ``sysfs`` to218control policy-specific aspects of driver behavior.219 220The generic attributes under :file:`/sys/devices/system/cpu/cpufreq/policyX/`221are the following:222 223``affected_cpus``224	List of online CPUs belonging to this policy (i.e. sharing the hardware225	performance scaling interface represented by the ``policyX`` policy226	object).227 228``bios_limit``229	If the platform firmware (BIOS) tells the OS to apply an upper limit to230	CPU frequencies, that limit will be reported through this attribute (if231	present).232 233	The existence of the limit may be a result of some (often unintentional)234	BIOS settings, restrictions coming from a service processor or another235	BIOS/HW-based mechanisms.236 237	This does not cover ACPI thermal limitations which can be discovered238	through a generic thermal driver.239 240	This attribute is not present if the scaling driver in use does not241	support it.242 243``cpuinfo_cur_freq``244	Current frequency of the CPUs belonging to this policy as obtained from245	the hardware (in KHz).246 247	This is expected to be the frequency the hardware actually runs at.248	If that frequency cannot be determined, this attribute should not249	be present.250 251``cpuinfo_max_freq``252	Maximum possible operating frequency the CPUs belonging to this policy253	can run at (in kHz).254 255``cpuinfo_min_freq``256	Minimum possible operating frequency the CPUs belonging to this policy257	can run at (in kHz).258 259``cpuinfo_transition_latency``260	The time it takes to switch the CPUs belonging to this policy from one261	P-state to another, in nanoseconds.262 263	If unknown or if known to be so high that the scaling driver does not264	work with the `ondemand`_ governor, -1 (:c:macro:`CPUFREQ_ETERNAL`)265	will be returned by reads from this attribute.266 267``related_cpus``268	List of all (online and offline) CPUs belonging to this policy.269 270``scaling_available_frequencies``271	List of available frequencies of the CPUs belonging to this policy272	(in kHz).273 274``scaling_available_governors``275	List of ``CPUFreq`` scaling governors present in the kernel that can276	be attached to this policy or (if the |intel_pstate| scaling driver is277	in use) list of scaling algorithms provided by the driver that can be278	applied to this policy.279 280	[Note that some governors are modular and it may be necessary to load a281	kernel module for the governor held by it to become available and be282	listed by this attribute.]283 284``scaling_cur_freq``285	Current frequency of all of the CPUs belonging to this policy (in kHz).286 287	In the majority of cases, this is the frequency of the last P-state288	requested by the scaling driver from the hardware using the scaling289	interface provided by it, which may or may not reflect the frequency290	the CPU is actually running at (due to hardware design and other291	limitations).292 293	Some architectures (e.g. ``x86``) may attempt to provide information294	more precisely reflecting the current CPU frequency through this295	attribute, but that still may not be the exact current CPU frequency as296	seen by the hardware at the moment.297 298``scaling_driver``299	The scaling driver currently in use.300 301``scaling_governor``302	The scaling governor currently attached to this policy or (if the303	|intel_pstate| scaling driver is in use) the scaling algorithm304	provided by the driver that is currently applied to this policy.305 306	This attribute is read-write and writing to it will cause a new scaling307	governor to be attached to this policy or a new scaling algorithm308	provided by the scaling driver to be applied to it (in the309	|intel_pstate| case), as indicated by the string written to this310	attribute (which must be one of the names listed by the311	``scaling_available_governors`` attribute described above).312 313``scaling_max_freq``314	Maximum frequency the CPUs belonging to this policy are allowed to be315	running at (in kHz).316 317	This attribute is read-write and writing a string representing an318	integer to it will cause a new limit to be set (it must not be lower319	than the value of the ``scaling_min_freq`` attribute).320 321``scaling_min_freq``322	Minimum frequency the CPUs belonging to this policy are allowed to be323	running at (in kHz).324 325	This attribute is read-write and writing a string representing a326	non-negative integer to it will cause a new limit to be set (it must not327	be higher than the value of the ``scaling_max_freq`` attribute).328 329``scaling_setspeed``330	This attribute is functional only if the `userspace`_ scaling governor331	is attached to the given policy.332 333	It returns the last frequency requested by the governor (in kHz) or can334	be written to in order to set a new frequency for the policy.335 336 337Generic Scaling Governors338=========================339 340``CPUFreq`` provides generic scaling governors that can be used with all341scaling drivers.  As stated before, each of them implements a single, possibly342parametrized, performance scaling algorithm.343 344Scaling governors are attached to policy objects and different policy objects345can be handled by different scaling governors at the same time (although that346may lead to suboptimal results in some cases).347 348The scaling governor for a given policy object can be changed at any time with349the help of the ``scaling_governor`` policy attribute in ``sysfs``.350 351Some governors expose ``sysfs`` attributes to control or fine-tune the scaling352algorithms implemented by them.  Those attributes, referred to as governor353tunables, can be either global (system-wide) or per-policy, depending on the354scaling driver in use.  If the driver requires governor tunables to be355per-policy, they are located in a subdirectory of each policy directory.356Otherwise, they are located in a subdirectory under357:file:`/sys/devices/system/cpu/cpufreq/`.  In either case the name of the358subdirectory containing the governor tunables is the name of the governor359providing them.360 361``performance``362---------------363 364When attached to a policy object, this governor causes the highest frequency,365within the ``scaling_max_freq`` policy limit, to be requested for that policy.366 367The request is made once at that time the governor for the policy is set to368``performance`` and whenever the ``scaling_max_freq`` or ``scaling_min_freq``369policy limits change after that.370 371``powersave``372-------------373 374When attached to a policy object, this governor causes the lowest frequency,375within the ``scaling_min_freq`` policy limit, to be requested for that policy.376 377The request is made once at that time the governor for the policy is set to378``powersave`` and whenever the ``scaling_max_freq`` or ``scaling_min_freq``379policy limits change after that.380 381``userspace``382-------------383 384This governor does not do anything by itself.  Instead, it allows user space385to set the CPU frequency for the policy it is attached to by writing to the386``scaling_setspeed`` attribute of that policy.387 388``schedutil``389-------------390 391This governor uses CPU utilization data available from the CPU scheduler.  It392generally is regarded as a part of the CPU scheduler, so it can access the393scheduler's internal data structures directly.394 395It runs entirely in scheduler context, although in some cases it may need to396invoke the scaling driver asynchronously when it decides that the CPU frequency397should be changed for a given policy (that depends on whether or not the driver398is capable of changing the CPU frequency from scheduler context).399 400The actions of this governor for a particular CPU depend on the scheduling class401invoking its utilization update callback for that CPU.  If it is invoked by the402RT or deadline scheduling classes, the governor will increase the frequency to403the allowed maximum (that is, the ``scaling_max_freq`` policy limit).  In turn,404if it is invoked by the CFS scheduling class, the governor will use the405Per-Entity Load Tracking (PELT) metric for the root control group of the406given CPU as the CPU utilization estimate (see the *Per-entity load tracking*407LWN.net article [1]_ for a description of the PELT mechanism).  Then, the new408CPU frequency to apply is computed in accordance with the formula409 410	f = 1.25 * ``f_0`` * ``util`` / ``max``411 412where ``util`` is the PELT number, ``max`` is the theoretical maximum of413``util``, and ``f_0`` is either the maximum possible CPU frequency for the given414policy (if the PELT number is frequency-invariant), or the current CPU frequency415(otherwise).416 417This governor also employs a mechanism allowing it to temporarily bump up the418CPU frequency for tasks that have been waiting on I/O most recently, called419"IO-wait boosting".  That happens when the :c:macro:`SCHED_CPUFREQ_IOWAIT` flag420is passed by the scheduler to the governor callback which causes the frequency421to go up to the allowed maximum immediately and then draw back to the value422returned by the above formula over time.423 424This governor exposes only one tunable:425 426``rate_limit_us``427	Minimum time (in microseconds) that has to pass between two consecutive428	runs of governor computations (default: 1.5 times the scaling driver's429	transition latency or the maximum 2ms).430 431	The purpose of this tunable is to reduce the scheduler context overhead432	of the governor which might be excessive without it.433 434This governor generally is regarded as a replacement for the older `ondemand`_435and `conservative`_ governors (described below), as it is simpler and more436tightly integrated with the CPU scheduler, its overhead in terms of CPU context437switches and similar is less significant, and it uses the scheduler's own CPU438utilization metric, so in principle its decisions should not contradict the439decisions made by the other parts of the scheduler.440 441``ondemand``442------------443 444This governor uses CPU load as a CPU frequency selection metric.445 446In order to estimate the current CPU load, it measures the time elapsed between447consecutive invocations of its worker routine and computes the fraction of that448time in which the given CPU was not idle.  The ratio of the non-idle (active)449time to the total CPU time is taken as an estimate of the load.450 451If this governor is attached to a policy shared by multiple CPUs, the load is452estimated for all of them and the greatest result is taken as the load estimate453for the entire policy.454 455The worker routine of this governor has to run in process context, so it is456invoked asynchronously (via a workqueue) and CPU P-states are updated from457there if necessary.  As a result, the scheduler context overhead from this458governor is minimum, but it causes additional CPU context switches to happen459relatively often and the CPU P-state updates triggered by it can be relatively460irregular.  Also, it affects its own CPU load metric by running code that461reduces the CPU idle time (even though the CPU idle time is only reduced very462slightly by it).463 464It generally selects CPU frequencies proportional to the estimated load, so that465the value of the ``cpuinfo_max_freq`` policy attribute corresponds to the load of4661 (or 100%), and the value of the ``cpuinfo_min_freq`` policy attribute467corresponds to the load of 0, unless when the load exceeds a (configurable)468speedup threshold, in which case it will go straight for the highest frequency469it is allowed to use (the ``scaling_max_freq`` policy limit).470 471This governor exposes the following tunables:472 473``sampling_rate``474	This is how often the governor's worker routine should run, in475	microseconds.476 477	Typically, it is set to values of the order of 2000 (2 ms).  Its478	default value is to add a 50% breathing room479	to ``cpuinfo_transition_latency`` on each policy this governor is480	attached to. The minimum is typically the length of two scheduler481	ticks.482 483	If this tunable is per-policy, the following shell command sets the time484	represented by it to be 1.5 times as high as the transition latency485	(the default)::486 487	# echo `$(($(cat cpuinfo_transition_latency) * 3 / 2)) > ondemand/sampling_rate488 489``up_threshold``490	If the estimated CPU load is above this value (in percent), the governor491	will set the frequency to the maximum value allowed for the policy.492	Otherwise, the selected frequency will be proportional to the estimated493	CPU load.494 495``ignore_nice_load``496	If set to 1 (default 0), it will cause the CPU load estimation code to497	treat the CPU time spent on executing tasks with "nice" levels greater498	than 0 as CPU idle time.499 500	This may be useful if there are tasks in the system that should not be501	taken into account when deciding what frequency to run the CPUs at.502	Then, to make that happen it is sufficient to increase the "nice" level503	of those tasks above 0 and set this attribute to 1.504 505``sampling_down_factor``506	Temporary multiplier, between 1 (default) and 100 inclusive, to apply to507	the ``sampling_rate`` value if the CPU load goes above ``up_threshold``.508 509	This causes the next execution of the governor's worker routine (after510	setting the frequency to the allowed maximum) to be delayed, so the511	frequency stays at the maximum level for a longer time.512 513	Frequency fluctuations in some bursty workloads may be avoided this way514	at the cost of additional energy spent on maintaining the maximum CPU515	capacity.516 517``powersave_bias``518	Reduction factor to apply to the original frequency target of the519	governor (including the maximum value used when the ``up_threshold``520	value is exceeded by the estimated CPU load) or sensitivity threshold521	for the AMD frequency sensitivity powersave bias driver522	(:file:`drivers/cpufreq/amd_freq_sensitivity.c`), between 0 and 1000523	inclusive.524 525	If the AMD frequency sensitivity powersave bias driver is not loaded,526	the effective frequency to apply is given by527 528		f * (1 - ``powersave_bias`` / 1000)529 530	where f is the governor's original frequency target.  The default value531	of this attribute is 0 in that case.532 533	If the AMD frequency sensitivity powersave bias driver is loaded, the534	value of this attribute is 400 by default and it is used in a different535	way.536 537	On Family 16h (and later) AMD processors there is a mechanism to get a538	measured workload sensitivity, between 0 and 100% inclusive, from the539	hardware.  That value can be used to estimate how the performance of the540	workload running on a CPU will change in response to frequency changes.541 542	The performance of a workload with the sensitivity of 0 (memory-bound or543	IO-bound) is not expected to increase at all as a result of increasing544	the CPU frequency, whereas workloads with the sensitivity of 100%545	(CPU-bound) are expected to perform much better if the CPU frequency is546	increased.547 548	If the workload sensitivity is less than the threshold represented by549	the ``powersave_bias`` value, the sensitivity powersave bias driver550	will cause the governor to select a frequency lower than its original551	target, so as to avoid over-provisioning workloads that will not benefit552	from running at higher CPU frequencies.553 554``conservative``555----------------556 557This governor uses CPU load as a CPU frequency selection metric.558 559It estimates the CPU load in the same way as the `ondemand`_ governor described560above, but the CPU frequency selection algorithm implemented by it is different.561 562Namely, it avoids changing the frequency significantly over short time intervals563which may not be suitable for systems with limited power supply capacity (e.g.564battery-powered).  To achieve that, it changes the frequency in relatively565small steps, one step at a time, up or down - depending on whether or not a566(configurable) threshold has been exceeded by the estimated CPU load.567 568This governor exposes the following tunables:569 570``freq_step``571	Frequency step in percent of the maximum frequency the governor is572	allowed to set (the ``scaling_max_freq`` policy limit), between 0 and573	100 (5 by default).574 575	This is how much the frequency is allowed to change in one go.  Setting576	it to 0 will cause the default frequency step (5 percent) to be used577	and setting it to 100 effectively causes the governor to periodically578	switch the frequency between the ``scaling_min_freq`` and579	``scaling_max_freq`` policy limits.580 581``down_threshold``582	Threshold value (in percent, 20 by default) used to determine the583	frequency change direction.584 585	If the estimated CPU load is greater than this value, the frequency will586	go up (by ``freq_step``).  If the load is less than this value (and the587	``sampling_down_factor`` mechanism is not in effect), the frequency will588	go down.  Otherwise, the frequency will not be changed.589 590``sampling_down_factor``591	Frequency decrease deferral factor, between 1 (default) and 10592	inclusive.593 594	It effectively causes the frequency to go down ``sampling_down_factor``595	times slower than it ramps up.596 597 598Frequency Boost Support599=======================600 601Background602----------603 604Some processors support a mechanism to raise the operating frequency of some605cores in a multicore package temporarily (and above the sustainable frequency606threshold for the whole package) under certain conditions, for example if the607whole chip is not fully utilized and below its intended thermal or power budget.608 609Different names are used by different vendors to refer to this functionality.610For Intel processors it is referred to as "Turbo Boost", AMD calls it611"Turbo-Core" or (in technical documentation) "Core Performance Boost" and so on.612As a rule, it also is implemented differently by different vendors.  The simple613term "frequency boost" is used here for brevity to refer to all of those614implementations.615 616The frequency boost mechanism may be either hardware-based or software-based.617If it is hardware-based (e.g. on x86), the decision to trigger the boosting is618made by the hardware (although in general it requires the hardware to be put619into a special state in which it can control the CPU frequency within certain620limits).  If it is software-based (e.g. on ARM), the scaling driver decides621whether or not to trigger boosting and when to do that.622 623The ``boost`` File in ``sysfs``624-------------------------------625 626This file is located under :file:`/sys/devices/system/cpu/cpufreq/` and controls627the "boost" setting for the whole system.  It is not present if the underlying628scaling driver does not support the frequency boost mechanism (or supports it,629but provides a driver-specific interface for controlling it, like630|intel_pstate|).631 632If the value in this file is 1, the frequency boost mechanism is enabled.  This633means that either the hardware can be put into states in which it is able to634trigger boosting (in the hardware-based case), or the software is allowed to635trigger boosting (in the software-based case).  It does not mean that boosting636is actually in use at the moment on any CPUs in the system.  It only means a637permission to use the frequency boost mechanism (which still may never be used638for other reasons).639 640If the value in this file is 0, the frequency boost mechanism is disabled and641cannot be used at all.642 643The only values that can be written to this file are 0 and 1.644 645Rationale for Boost Control Knob646--------------------------------647 648The frequency boost mechanism is generally intended to help to achieve optimum649CPU performance on time scales below software resolution (e.g. below the650scheduler tick interval) and it is demonstrably suitable for many workloads, but651it may lead to problems in certain situations.652 653For this reason, many systems make it possible to disable the frequency boost654mechanism in the platform firmware (BIOS) setup, but that requires the system to655be restarted for the setting to be adjusted as desired, which may not be656practical at least in some cases.  For example:657 658  1. Boosting means overclocking the processor, although under controlled659     conditions.  Generally, the processor's energy consumption increases660     as a result of increasing its frequency and voltage, even temporarily.661     That may not be desirable on systems that switch to power sources of662     limited capacity, such as batteries, so the ability to disable the boost663     mechanism while the system is running may help there (but that depends on664     the workload too).665 666  2. In some situations deterministic behavior is more important than667     performance or energy consumption (or both) and the ability to disable668     boosting while the system is running may be useful then.669 670  3. To examine the impact of the frequency boost mechanism itself, it is useful671     to be able to run tests with and without boosting, preferably without672     restarting the system in the meantime.673 674  4. Reproducible results are important when running benchmarks.  Since675     the boosting functionality depends on the load of the whole package,676     single-thread performance may vary because of it which may lead to677     unreproducible results sometimes.  That can be avoided by disabling the678     frequency boost mechanism before running benchmarks sensitive to that679     issue.680 681Legacy AMD ``cpb`` Knob682-----------------------683 684The AMD powernow-k8 scaling driver supports a ``sysfs`` knob very similar to685the global ``boost`` one.  It is used for disabling/enabling the "Core686Performance Boost" feature of some AMD processors.687 688If present, that knob is located in every ``CPUFreq`` policy directory in689``sysfs`` (:file:`/sys/devices/system/cpu/cpufreq/policyX/`) and is called690``cpb``, which indicates a more fine grained control interface.  The actual691implementation, however, works on the system-wide basis and setting that knob692for one policy causes the same value of it to be set for all of the other693policies at the same time.694 695That knob is still supported on AMD processors that support its underlying696hardware feature, but it may be configured out of the kernel (via the697:c:macro:`CONFIG_X86_ACPI_CPUFREQ_CPB` configuration option) and the global698``boost`` knob is present regardless.  Thus it is always possible use the699``boost`` knob instead of the ``cpb`` one which is highly recommended, as that700is more consistent with what all of the other systems do (and the ``cpb`` knob701may not be supported any more in the future).702 703The ``cpb`` knob is never present for any processors without the underlying704hardware feature (e.g. all Intel ones), even if the705:c:macro:`CONFIG_X86_ACPI_CPUFREQ_CPB` configuration option is set.706 707 708References709==========710 711.. [1] Jonathan Corbet, *Per-entity load tracking*,712       https://lwn.net/Articles/531853/713