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
272 It first uses a simple pattern recognition algorithm to obtain a preliminary
276 milliseconds) or it is small relative to the average (the average is greater
283 the "typical interval" is assumed to equal "infinity" (the maximum unsigned
288 tick will be stopped. That time, referred to as the *sleep length* in what follows,
289 is the upper bound on the time before the next CPU wakeup. It is used to determine
290 the sleep length range, which in turn is needed to get the sleep length correction
294 values that correspond to different sleep length ranges organized so that each
300 up and the closer the sleep length is to the observed idle duration, the closer
301 to 1 the correction factor becomes (it must fall between 0 and 1 inclusive).
303 falls into to obtain an approximation of the predicted idle duration that is
304 compared to the "typical interval" determined previously and the minimum of
308 to be woken up soon enough, the sleep length computation is skipped as it may
309 be costly and the idle duration is simply predicted to equal the "typical
312 Now, the governor is ready to walk the list of idle states and choose one of
316 framework. It selects the state with the target residency closest to the predicted
320 In the final step the governor may still need to refine the idle state selection
321 if it has not decided to `stop the scheduler tick <idle-cpus-and-tick_>`_. That
326 that time, the governor may need to select a shallower state with a suitable
337 <menu-gov_>`_: it always tries to find the deepest idle state suitable for the
338 given conditions. However, it applies a different approach to that problem.
349 supported by the processor have to be represented as a one-dimensional array of
350 |struct cpuidle_state| objects each allowing an individual (logical) CPU to ask
351 the processor hardware to enter an idle state of certain properties. If there
359 For example, take a processor with two cores in a larger unit referred to as
360 a "module" and suppose that asking the hardware to enter a specific idle state
361 (say "X") at the "core" level by one core will trigger the module to try to
364 level gives the hardware a license to go as deep as to idle state "MX" at the
365 "module" level, but there is no guarantee that this is going to happen (the core
368 idle state "X" must reflect the minimum time to spend in idle state "MX" of
369 the module (including the time needed to enter it), because that is the minimum
370 time the CPU needs to be idle to save any energy in case the hardware enters
374 will start to execute the first new instruction (assuming that both cores in the
375 module will always be ready to execute instructions as soon as the module
383 entirely up to the driver, but still the physical properties of the idle state
389 In addition to the target residency and exit latency idle state parameters
391 parameters describing the idle state and a pointer to the function to run in
392 order to ask the hardware to enter that state. Also, for each
399 directory in ``sysfs``, where the number ``<N>`` is assigned to the given
401 called :file:`state0`, :file:`state1` and so on, up to the number of idle state
403 corresponds to one idle state object and the larger the number in its name, the
406 object corresponding to it, as follows:
410 observed idle duration was certainly too short to match its target
445 Total number of times the hardware has been asked by the given CPU to
449 Total number of times a request to enter this idle state on the given
453 between them is that the name is expected to be more concise, while the
460 driver will never ask the hardware to enter it for that CPU as a result.
462 asked for by the other CPUs, so it must be disabled for all of them in order to
463 never be asked for by any of them. [Note that, due to the way the ``ladder``
469 CPUs in the system at the same time. Writing 1 to it causes the idle state to
470 be disabled for this particular CPU and writing 0 to it allows the governor to
471 take it into consideration for the given CPU and the driver to ask for it,
477 hierarchy of units in the processor, and it generally is hard to obtain idle
484 the kernel and it may not cover the cases in which the hardware refused to enter
487 asking the hardware to enter an idle state and the subsequent wakeup of the CPU
492 particular case. For these reasons, the only reliable way to find out how
494 it is to use idle state residency counters in the hardware, if available.
496 Generally, an interrupt received when trying to enter an idle state causes the
497 idle state entry request to be rejected, in which case the ``CPUIdle`` driver
498 may return an error code to indicate that this was the case. The :file:`usage`
508 allows kernel code and user space processes to set constraints on various
509 energy-efficiency features of the kernel to prevent performance from dropping
518 signed 32-bit integer) to it. In turn, the resume latency constraint for a CPU
520 32-bit integer) to the :file:`power/pm_qos_resume_latency_us` file under
535 PM QoS request to be created and added to a global priority list of CPU latency
538 number written to it will be associated with the PM QoS request represented by
540 used to determine the new effective value of the entire list of requests and
553 with that file descriptor to be removed from the global priority list of CPU
555 mechanism will be used again, to determine the new effective value for the whole
560 :file:`/sys/devices/system/cpu/cpu<N>/` in ``sysfs`` and writing to it causes
561 this single PM QoS request to be updated regardless of which user space
563 user space, so access to the file associated with it needs to be arbitrated
564 to avoid confusion. [Arguably, the only legitimate use of this mechanism in
565 practice is to pin a process to the CPU in question and let it use the
566 ``sysfs`` interface to control the resume latency constraint for it.] It is
567 still only a request, however. It is an entry in a priority list used to
568 determine the effective value to be set as the resume latency constraint for the
572 CPU idle time governors are expected to regard the minimum of the global
575 they are allowed to select for that CPU. They should never select any idle
582 In addition to the ``sysfs`` interface allowing individual idle states to be
586 The ``cpuidle.off=1`` kernel command line option can be used to disable the
589 from being invoked. If it is added to the kernel command line, the idle loop
590 will ask the hardware to enter idle states on idle CPUs via the CPU architecture
591 support code that is expected to provide a default mechanism for this purpose.
598 governor to use to be specified. It has to be appended with a string matching
600 governor will be used instead of the default one. It is possible to force
601 the ``menu`` governor to be used on the systems that use the ``ladder`` governor
606 to ``intel_idle`` affect Intel processors only.
609 options related to CPU idle time management: ``idle=poll``, ``idle=halt``,
612 ``CPUIdle`` subsystem to be disabled and makes the idle loop invoke the
613 architecture support code to deal with idle CPUs. How it does that depends on
614 which of the two parameters is added to the kernel command line. In the
617 and causes the hardware to attempt to enter the shallowest available idle state)
623 P-states (see |cpufreq|) that require any number of CPUs in a package to be
629 the CPU to enter idle states. When this option is used, the ``acpi_idle``
636 In addition to the architecture-level kernel command line options affecting CPU
638 drivers that can be passed to them via the kernel command line. Specifically,
643 ``intel_idle`` and ``acpi_idle`` drivers, respectively, to discard all of the
645 for any of those idle states or expose them to the governor. [The behavior of
646 the two drivers is different for ``<n>`` equal to ``0``. Adding
647 ``intel_idle.max_cstate=0`` to the kernel command line disables the
648 ``intel_idle`` driver and allows ``acpi_idle`` to be used, whereas
649 ``processor.max_cstate=0`` is equivalent to ``processor.max_cstate=1``.
651 can be loaded separately and ``max_cstate=<n>`` can be passed to it as a module