Lines Matching full:to

19 Modern processors are generally able to enter states in which the execution of
20 a program is suspended and instructions belonging to it are not fetched from
24 generally allows power drawn by the processor to be reduced and, in consequence,
25 it is an opportunity to save energy.
36 not be separate physical entities and may just be interfaces appearing to
38 entity which appears to be fetching instructions that belong to one sequence
43 program) at a time, it is a CPU. In that case, if the hardware is asked to
44 enter an idle state, that applies to the processor as a whole.
46 Second, if the processor is multi-core, each core in it is able to follow at
51 time. The entire cores are CPUs in that case and if the hardware is asked to
52 enter an idle state, that applies to the core that asked for it in the first
53 place, but it also may apply to a larger unit (say a "package" or a "cluster")
54 that the core belongs to (in fact, it may apply to an entire hierarchy of larger
57 remaining core asks the processor to enter an idle state, that may trigger it
58 to put the whole larger unit into an idle state which also will affect the
61 Finally, each core in a multi-core processor may be able to follow more than one
62 program in the same time frame (that is, each core may be able to fetch
65 the cores present themselves to software as "bundles" each consisting of
66 multiple individual single-core "processors", referred to as *hardware threads*
69 time management perspective and if the processor is asked to enter an idle state
72 core also have asked the processor to enter an idle state. In that situation,
80 Logical CPUs, simply referred to as "CPUs" in what follows, are regarded as
81 *idle* by the Linux kernel when there are no tasks to run on them except for the
85 sequence of instructions to execute, or code, data to be manipulated while
86 running that code, and some context information that needs to be loaded into the
88 distributes work by assigning tasks to run to the CPUs present in the system.
93 events to occur or similar). When a task becomes runnable, the CPU scheduler
94 assigns it to one of the available CPUs to run and if there are no more runnable
95 tasks assigned to it, the CPU will load the given task's context and run its
97 another CPU). [If there are multiple runnable tasks assigned to one CPU
98 simultaneously, they will be subject to prioritization and time sharing in order
99 to allow them to make some progress over time.]
102 assigned to the given CPU and the CPU is then regarded as idle. In other words,
104 code may cause the processor to be put into one of its idle states, if they are
105 supported, in order to save energy, but if the processor does not support any
106 idle states, or there is not enough time to spend in an idle state before the
109 useless instructions in a loop until it is assigned a new task to run.
118 calls into a code module referred to as the *governor* that belongs to the CPU
119 idle time management subsystem called ``CPUIdle`` to select an idle state for
120 the CPU to ask the hardware to enter. Second, it invokes another code module
121 from the ``CPUIdle`` subsystem, called the *driver*, to actually ask the
122 processor hardware to enter the idle state selected by the governor.
124 The role of the governor is to find an idle state most suitable for the
126 asked to enter by logical CPUs are represented in an abstract way independent of
128 (linear) array. That array has to be prepared and supplied by the ``CPUIdle``
130 time. This allows ``CPUIdle`` governors to be independent of the underlying
131 hardware and to work with any platforms that the Linux kernel can run on.
133 Each idle state present in that array is characterized by two parameters to be
136 spend in the given state, including the time needed to enter it (which may be
137 substantial), in order to save more energy than it would save by entering one of
139 corresponds to the power drawn by the processor in that state.] The exit
141 hardware to enter an idle state to start executing the first instruction after a
143 the time needed to enter the given state in case the wakeup occurs when the
144 hardware is entering it and it must be entered completely to be exited in an
151 CPU depends on can spend in an idle state, including the time necessary to enter
155 was idle after it has been woken up (that time will be referred to as the *idle
157 time until the closest timer to estimate the idle duration in future. How the
176 hardcoded idle states information and the other able to read that information
179 decision on which one of them to use has to be made early (on Intel platforms
191 The scheduler tick is a timer that triggers periodically in order to implement
193 multiple runnable tasks assigned to one CPU at the same time, the only way to
194 allow them to make reasonable progress in a given time frame is to make them
196 given a slice of the CPU time to run its code, subject to the scheduling class,
198 switched over to running (the code of) another task. The currently running task
199 may not want to give the CPU away voluntarily, however, and the scheduler tick
200 is there to make the switch happen regardless. That is not the only role of the
206 Thus, if the tick is allowed to trigger on idle CPUs, it will not make sense
207 for them to ask the hardware to enter idle states with target residencies above
210 exiting idle states due to the tick wakeups on idle CPUs will be wasted.
212 Fortunately, it is not really necessary to allow the tick to trigger on idle
213 CPUs, because (by definition) they have no tasks to run except for the special
217 tick goes away if the given CPU is idle. Consequently, it is possible to stop
221 Whether or not it makes sense to stop the scheduler tick in the idle loop
223 (non-tick) timer due to trigger within the tick range, stopping the tick clearly
224 would be a waste of time, even though the timer hardware may not need to be
229 going to be relatively shallow. The governor really cannot select a deep idle
232 waste of time and in this case the timer hardware would need to be reprogrammed,
237 tick range, it is better to allow the tick trigger. Otherwise, however, the
242 or not to stop the scheduler tick belongs to it. Still, if the tick has been
244 to leave it as is and the governor needs to take that into account.
246 The kernel can be configured to disable stopping the scheduler tick in the idle
249 ``nohz=off`` to it in the command line. In both cases, as the stopping of the
253 The systems that run kernels configured to allow the scheduler tick to be
254 stopped on idle CPUs are referred to as *tickless* systems and they are
268 Namely, when invoked to select an idle state for a CPU (i.e. an idle state that
269 the CPU will ask the processor hardware to enter), it attempts to predict the
273 that the scheduler tick will be stopped. That time, referred to as the *sleep
275 wakeup. It is used to determine the sleep length range, which in turn is needed
276 to get the sleep length correction factor.
280 for some I/O operations to complete and the other one is used when that is not
282 to different sleep length ranges organized so that each range represented in the
287 up and the closer the sleep length is to the observed idle duration, the closer
288 to 1 the correction factor becomes (it must fall between 0 and 1 inclusive).
290 falls into to obtain the first approximation of the predicted idle duration.
292 Next, the governor uses a simple pattern recognition algorithm to refine its
296 milliseconds) or it is small relative to the average (the average is greater
303 the "typical interval" is assumed to equal "infinity" (the maximum unsigned
308 Then, the governor computes an extra latency limit to help "interactive"
311 in that state probably will be very short and the amount of energy to save by
312 entering it will be relatively small, so likely it is better to avoid the
313 overhead related to entering that state and exiting it. Thus selecting a
314 shallower state is likely to be a better option then. The first approximation
317 previously ran on the given CPU and now they are waiting for I/O operations to
323 Now, the governor is ready to walk the list of idle states and choose one of
326 limit. It selects the state with the target residency closest to the predicted
330 In the final step the governor may still need to refine the idle state selection
331 if it has not decided to `stop the scheduler tick <idle-cpus-and-tick_>`_. That
336 that time, the governor may need to select a shallower state with a suitable
347 <menu-gov_>`_: it always tries to find the deepest idle state suitable for the
348 given conditions. However, it applies a different approach to that problem.
351 to correlate the observed idle duration values with the available idle states
352 and use that information to pick up the idle state that is most likely to
355 operations to complete now at all (there is no guarantee that they will run on
361 Like in the ``menu`` governor `case <menu-gov_>`_, the first step is to obtain
364 on the time until the next CPU wakeup). That value is then used to preselect an
370 sleep length. They both are subject to decay (after a CPU wakeup) every time
371 the target residency of the idle state corresponding to them is less than or
372 equal to the sleep length and the target residency of the next idle state is
373 greater than the sleep length (that is, when the idle state corresponding to
376 is less than or equal to the observed idle duration and the target residency of
385 sleep length. It is subject to decay on every CPU wakeup and it is increased
386 when the idle state corresponding to it "matches" the observed (post-wakeup)
388 equal to the sleep length (i.e. the idle state "matching" the sleep length is
393 to the sleep length. Then, the ``hits`` and ``misses`` metrics of that idle
395 greater (which means that that idle state is likely to "match" the observed idle
407 into consideration and if at least a half of them are greater than or equal to
409 final candidate to ask for. Otherwise, the average of the most recent idle
413 That idle state is then taken as the final candidate to ask for.
415 Still, at this point the governor may need to refine the idle state selection if
416 it has not decided to `stop the scheduler tick <idle-cpus-and-tick_>`_. That
422 than that time, a shallower state with a suitable target residency may need to
432 supported by the processor have to be represented as a one-dimensional array of
433 |struct cpuidle_state| objects each allowing an individual (logical) CPU to ask
434 the processor hardware to enter an idle state of certain properties. If there
442 For example, take a processor with two cores in a larger unit referred to as
443 a "module" and suppose that asking the hardware to enter a specific idle state
444 (say "X") at the "core" level by one core will trigger the module to try to
447 level gives the hardware a license to go as deep as to idle state "MX" at the
448 "module" level, but there is no guarantee that this is going to happen (the core
451 idle state "X" must reflect the minimum time to spend in idle state "MX" of
452 the module (including the time needed to enter it), because that is the minimum
453 time the CPU needs to be idle to save any energy in case the hardware enters
457 will start to execute the first new instruction (assuming that both cores in the
458 module will always be ready to execute instructions as soon as the module
466 entirely up to the driver, but still the physical properties of the idle state
472 In addition to the target residency and exit latency idle state parameters
474 parameters describing the idle state and a pointer to the function to run in
475 order to ask the hardware to enter that state. Also, for each
482 directory in ``sysfs``, where the number ``<N>`` is assigned to the given
484 called :file:`state0`, :file:`state1` and so on, up to the number of idle state
486 corresponds to one idle state object and the larger the number in its name, the
489 object corresponding to it, as follows:
493 observed idle duration was certainly too short to match its target
528 Total number of times the hardware has been asked by the given CPU to
532 Total number of times a request to enter this idle state on the given
536 between them is that the name is expected to be more concise, while the
543 driver will never ask the hardware to enter it for that CPU as a result.
545 asked for by the other CPUs, so it must be disabled for all of them in order to
546 never be asked for by any of them. [Note that, due to the way the ``ladder``
552 CPUs in the system at the same time. Writing 1 to it causes the idle state to
553 be disabled for this particular CPU and writing 0 to it allows the governor to
554 take it into consideration for the given CPU and the driver to ask for it,
560 hierarchy of units in the processor, and it generally is hard to obtain idle
567 the kernel and it may not cover the cases in which the hardware refused to enter
570 asking the hardware to enter an idle state and the subsequent wakeup of the CPU
575 particular case. For these reasons, the only reliable way to find out how
577 it is to use idle state residency counters in the hardware, if available.
579 Generally, an interrupt received when trying to enter an idle state causes the
580 idle state entry request to be rejected, in which case the ``CPUIdle`` driver
581 may return an error code to indicate that this was the case. The :file:`usage`
591 allows kernel code and user space processes to set constraints on various
592 energy-efficiency features of the kernel to prevent performance from dropping
601 signed 32-bit integer) to it. In turn, the resume latency constraint for a CPU
603 32-bit integer) to the :file:`power/pm_qos_resume_latency_us` file under
618 PM QoS request to be created and added to a global priority list of CPU latency
621 number written to it will be associated with the PM QoS request represented by
623 used to determine the new effective value of the entire list of requests and
636 with that file descriptor to be removed from the global priority list of CPU
638 mechanism will be used again, to determine the new effective value for the whole
643 :file:`/sys/devices/system/cpu/cpu<N>/` in ``sysfs`` and writing to it causes
644 this single PM QoS request to be updated regardless of which user space
646 user space, so access to the file associated with it needs to be arbitrated
647 to avoid confusion. [Arguably, the only legitimate use of this mechanism in
648 practice is to pin a process to the CPU in question and let it use the
649 ``sysfs`` interface to control the resume latency constraint for it.] It is
650 still only a request, however. It is an entry in a priority list used to
651 determine the effective value to be set as the resume latency constraint for the
655 CPU idle time governors are expected to regard the minimum of the global
658 they are allowed to select for that CPU. They should never select any idle
665 In addition to the ``sysfs`` interface allowing individual idle states to be
669 The ``cpuidle.off=1`` kernel command line option can be used to disable the
672 from being invoked. If it is added to the kernel command line, the idle loop
673 will ask the hardware to enter idle states on idle CPUs via the CPU architecture
674 support code that is expected to provide a default mechanism for this purpose.
681 governor to use to be specified. It has to be appended with a string matching
683 governor will be used instead of the default one. It is possible to force
684 the ``menu`` governor to be used on the systems that use the ``ladder`` governor
692 options related to CPU idle time management: ``idle=poll``, ``idle=halt``,
695 ``CPUIdle`` subsystem to be disabled and makes the idle loop invoke the
696 architecture support code to deal with idle CPUs. How it does that depends on
697 which of the two parameters is added to the kernel command line. In the
700 and causes the hardware to attempt to enter the shallowest available idle state)
706 P-states (see |cpufreq|) that require any number of CPUs in a package to be
712 ``acpi_idle`` to be used (as long as all of the information needed by it is
713 there in the system's ACPI tables), but it is not allowed to use the
714 ``MWAIT`` instruction of the CPUs to ask the hardware to enter idle states.
716 In addition to the architecture-level kernel command line options affecting CPU
718 drivers that can be passed to them via the kernel command line. Specifically,
723 ``intel_idle`` and ``acpi_idle`` drivers, respectively, to discard all of the
725 for any of those idle states or expose them to the governor. [The behavior of
726 the two drivers is different for ``<n>`` equal to ``0``. Adding
727 ``intel_idle.max_cstate=0`` to the kernel command line disables the
728 ``intel_idle`` driver and allows ``acpi_idle`` to be used, whereas
729 ``processor.max_cstate=0`` is equivalent to ``processor.max_cstate=1``.
731 can be loaded separately and ``max_cstate=<n>`` can be passed to it as a module