Lines Matching full:idle
8 CPU Idle Time Management
21 memory or executed. Those states are the *idle* states of the processor.
23 Since part of the processor hardware is not used in idle states, entering them
27 CPU idle time management is an energy-efficiency feature concerned about using
28 the idle states of processors for this purpose.
33 CPU idle time management operates on CPUs as seen by the *CPU scheduler* (that
44 enter an idle state, that applies to the processor as a whole.
52 enter an idle state, that applies to the core that asked for it in the first
56 except for one have been put into idle states at the "core level" and the
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
68 sequence of instructions. Then, the hardware threads are CPUs from the CPU idle
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,
73 the core may be put into an idle state individually or a larger unit containing
74 it may be put into an idle state as a whole (if the other cores within the
75 larger unit are in idle states already).
77 Idle CPUs
81 *idle* by the Linux kernel when there are no tasks to run on them except for the
82 special "idle" task.
101 The special "idle" task becomes runnable if there are no other runnable tasks
102 assigned to the given CPU and the CPU is then regarded as idle. In other words,
103 in Linux idle CPUs run the code of the "idle" task called *the idle loop*. That
104 code may cause the processor to be put into one of its idle states, if they are
106 idle states, or there is not enough time to spend in an idle state before the
108 available idle states from being used, the CPU will simply execute more or less
114 The Idle Loop
117 The idle loop code takes two major steps in every iteration of it. First, it
119 idle time management subsystem called ``CPUIdle`` to select an idle state for
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
125 conditions at hand. For this purpose, idle states that the hardware can be
133 Each idle state present in that array is characterized by two parameters to be
138 the shallower idle states instead. [The "depth" of an idle state roughly
141 hardware to enter an idle state to start executing the first instruction after a
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
165 `stopped by the idle loop <idle-cpus-and-tick_>`_. It is possible to change the
178 hardcoded idle states information and the other able to read that information
190 Idle CPUs and The Scheduler Tick
205 The scheduler tick is problematic from the CPU idle time management perspective,
208 Thus, if the tick is allowed to trigger on idle CPUs, it will not make sense
209 for them to ask the hardware to enter idle states with target residencies above
210 the tick period length. Moreover, in that case the idle duration of any CPU
212 exiting idle states due to the tick wakeups on idle CPUs will be wasted.
214 Fortunately, it is not really necessary to allow the tick to trigger on idle
216 "idle" one. In other words, from the CPU scheduler perspective, the only user
217 of the CPU time on them is the idle loop. Since the time of an idle CPU need
219 tick goes away if the given CPU is idle. Consequently, it is possible to stop
220 the scheduler tick entirely on idle CPUs in principle, even though that may not
223 Whether or not it makes sense to stop the scheduler tick in the idle loop
229 be harmful. Namely, in that case the governor will select an idle state with
231 going to be relatively shallow. The governor really cannot select a deep idle
237 in the shallow idle state selected by the governor, which will be a waste of
240 governor will select a relatively deep idle state, so the tick should be stopped
248 The kernel can be configured to disable stopping the scheduler tick in the idle
253 ignored by the idle loop code and the tick is never stopped.
256 stopped on idle CPUs are referred to as *tickless* systems and they are
270 Namely, when invoked to select an idle state for a CPU (i.e. an idle state that
272 idle duration and uses the predicted value for idle state selection.
288 selecting the idle state for the CPU) is updated after the CPU has been woken
289 up and the closer the sleep length is to the observed idle duration, the closer
292 falls into to obtain the first approximation of the predicted idle duration.
295 idle duration prediction. Namely, it saves the last 8 observed idle duration
296 values and, when predicting the idle duration next time, it computes the average
300 interval" value. Otherwise, the longest of the saved observed idle duration
308 taken as the predicted idle duration.
312 idle state is comparable with the predicted idle duration, the total time spent
317 of the extra latency limit is the predicted idle duration itself which
322 framework and the minimum of the two is taken as the limit for the idle states'
325 Now, the governor is ready to walk the list of idle states and choose one of
327 the predicted idle duration and the exit latency of it with the computed latency
329 idle duration, but still below it, and exit latency that does not exceed the
332 In the final step the governor may still need to refine the idle state selection
333 if it has not decided to `stop the scheduler tick <idle-cpus-and-tick_>`_. That
334 happens if the idle duration predicted by it is less than the tick period and
335 the tick has not been stopped already (in a previous iteration of the idle
349 <menu-gov_>`_: it always tries to find the deepest idle state suitable for the
353 to correlate the observed idle duration values with the available idle states
354 and use that information to pick up the idle state that is most likely to
355 "match" the upcoming CPU idle interval. Second, it does not take the tasks
359 it avoids taking timer wakeups into account. It also only uses idle duration
367 idle state on the basis of three metrics maintained for each idle state provided
370 The ``hits`` and ``misses`` metrics measure the likelihood that a given idle
371 state will "match" the observed (post-wakeup) idle duration if it "matches" the
373 the target residency of the idle state corresponding to them is less than or
374 equal to the sleep length and the target residency of the next idle state is
375 greater than the sleep length (that is, when the idle state corresponding to
377 former condition is satisfied and the target residency of the given idle state
378 is less than or equal to the observed idle duration and the target residency of
379 the next idle state is greater than the observed idle duration at the same time
380 (that is, it is increased when the given idle state "matches" both the sleep
381 length and the observed idle duration). In turn, the ``misses`` metric is
382 increased when the given idle state "matches" the sleep length only and the
383 observed idle duration is too short for its target residency.
385 The ``early_hits`` metric measures the likelihood that a given idle state will
386 "match" the observed (post-wakeup) idle duration if it does not "match" the
388 when the idle state corresponding to it "matches" the observed (post-wakeup)
389 idle duration and the target residency of the next idle state is less than or
390 equal to the sleep length (i.e. the idle state "matching" the sleep length is
393 The governor walks the list of idle states provided by the ``CPUIdle`` driver
395 to the sleep length. Then, the ``hits`` and ``misses`` metrics of that idle
397 greater (which means that that idle state is likely to "match" the observed idle
399 preselects the shallower idle state with the maximum ``early_hits`` metric
400 (or if there are multiple shallower idle states with equal ``early_hits``
403 <cpu-pm-qos_>`_ which is hit before reaching the deepest idle state with the
404 target residency within the sleep length, the deepest idle state with the exit
408 Next, the governor takes several idle duration values observed most recently
410 the target residency of the preselected idle state, that idle state becomes the
411 final candidate to ask for. Otherwise, the average of the most recent idle
412 duration values below the target residency of the preselected idle state is
413 computed and the governor walks the idle states shallower than the preselected
415 That idle state is then taken as the final candidate to ask for.
417 Still, at this point the governor may need to refine the idle state selection if
418 it has not decided to `stop the scheduler tick <idle-cpus-and-tick_>`_. That
419 generally happens if the target residency of the idle state selected so far is
421 previous iteration of the idle loop). Then, like in the ``menu`` governor
430 Representation of Idle States
433 For the CPU idle time management purposes all of the physical idle states
436 the processor hardware to enter an idle state of certain properties. If there
438 cover a combination of idle states supported by the units at different levels of
440 of it <idle-loop_>`_, must reflect the properties of the idle state at the
441 deepest level (i.e. the idle state of the unit containing all of the other
445 a "module" and suppose that asking the hardware to enter a specific idle state
447 enter a specific idle state of its own (say "MX") if the other core is in idle
448 state "X" already. In other words, asking for idle state "X" at the "core"
449 level gives the hardware a license to go as deep as to idle state "MX" at the
451 asking for idle state "X" may just end up in that state by itself instead).
453 idle state "X" must reflect the minimum time to spend in idle state "MX" of
455 time the CPU needs to be idle to save any energy in case the hardware enters
457 the exit time of idle state "MX" of the module (and usually its entry time too),
464 hierarchy of units inside them, however. In those cases asking for an idle
467 handling of the hierarchy. Then, the definition of the idle state objects is
468 entirely up to the driver, but still the physical properties of the idle state
470 used by the governor for idle state selection (for instance, the actual exit
471 latency of that idle state must not exceed the exit latency parameter of the
472 idle state object selected by the governor).
474 In addition to the target residency and exit latency idle state parameters
475 discussed above, the objects representing idle states each contain a few other
476 parameters describing the idle state and a pointer to the function to run in
480 statistics of the given idle state. That information is exposed by the kernel
486 called :file:`state0`, :file:`state1` and so on, up to the number of idle state
488 corresponds to one idle state object and the larger the number in its name, the
489 deeper the (effective) idle state represented by it. Each of them contains
490 a number of files (attributes) representing the properties of the idle state
494 Total number of times this idle state had been asked for, but the
495 observed idle duration was certainly too short to match its target
499 Total number of times this idle state had been asked for, but cerainly
500 a deeper idle state would have been a better match for the observed idle
504 Description of the idle state.
507 Whether or not this idle state is disabled.
510 Exit latency of the idle state in microseconds.
513 Name of the idle state.
516 Power drawn by hardware in this idle state in milliwatts (if specified,
520 Target residency of the idle state in microseconds.
523 Total time spent in this idle state by the given CPU (as measured by the
528 enter this idle state.
536 given idle state is disabled for this particular CPU, which means that the
539 However, disabling an idle state for one CPU does not prevent it from being
542 governor is implemented, disabling an idle state prevents that governor from
543 selecting any idle states deeper than the disabled one too.]
545 If the :file:`disable` attribute contains 0, the given idle state is enabled for
547 CPUs in the system at the same time. Writing 1 to it causes the idle state to
553 The :file:`power` attribute is not defined very well, especially for idle state
554 objects representing combinations of idle states at different levels of the
555 hierarchy of units in the processor, and it generally is hard to obtain idle
561 really spent by the given CPU in the given idle state, because it is measured by
563 this idle state and entered a shallower one instead of it (or even it did not
564 enter any idle state at all). The kernel can only measure the time span between
565 asking the hardware to enter an idle state and the subsequent wakeup of the CPU
567 Moreover, if the idle state object in question represents a combination of idle
571 much time has been spent by the hardware in different idle states supported by
572 it is to use idle state residency counters in the hardware, if available.
587 CPU idle time management can be affected by PM QoS in two ways, through the
646 CPU idle time governors are expected to regard the minimum of the global
649 latency of the idle states they can select for that CPU. They should never
650 select any idle states with exit latency beyond that limit.
653 Idle States Control Via Kernel Command Line
656 In addition to the ``sysfs`` interface allowing individual idle states to be
657 `disabled for individual CPUs <idle-states-representation_>`_, there are kernel
658 command line parameters affecting CPU idle time management.
661 CPU idle time management entirely. It does not prevent the idle loop from
662 running on idle CPUs, but it prevents the CPU idle time governors and drivers
663 from being invoked. If it is added to the kernel command line, the idle loop
664 will ask the hardware to enter idle states on idle CPUs via the CPU architecture
678 The other kernel command line parameters controlling CPU idle time management
683 options related to CPU idle time management: ``idle=poll``, ``idle=halt``,
684 and ``idle=nomwait``. The first two of them disable the ``acpi_idle`` and
686 ``CPUIdle`` subsystem to be disabled and makes the idle loop invoke the
687 architecture support code to deal with idle CPUs. How it does that depends on
689 ``idle=halt`` case, the architecture support code will use the ``HLT``
691 and causes the hardware to attempt to enter the shallowest available idle state)
692 for this purpose, and if ``idle=poll`` is used, idle CPUs will execute a
694 that using ``idle=poll`` is somewhat drastic in many cases, as preventing idle
698 idle, so it very well may hurt single-thread computations performance as well as
702 The ``idle=nomwait`` option disables the ``intel_idle`` driver and causes
705 ``MWAIT`` instruction of the CPUs to ask the hardware to enter idle states.
708 idle time management, there are parameters affecting individual ``CPUIdle``
711 where ``<n>`` is an idle state index also used in the name of the given
713 `Representation of Idle States <idle-states-representation_>`_), causes the
715 idle states deeper than idle state ``<n>``. In that case, they will never ask
716 for any of those idle states or expose them to the governor. [The behavior of