Lines Matching +full:cpu +full:- +full:core
1 .. SPDX-License-Identifier: GPL-2.0
5 .. |cpufreq| replace:: :doc:`CPU Performance Scaling <cpufreq>`
8 CPU Idle Time Management
27 CPU idle time management is an energy-efficiency feature concerned about using
31 ------------
33 CPU idle time management operates on CPUs as seen by the *CPU scheduler* (that
37 software as individual single-core processors. In other words, a CPU is an
43 program) at a time, it is a CPU. In that case, if the hardware is asked to
46 Second, if the processor is multi-core, each core in it is able to follow at
52 enter an idle state, that applies to the core that asked for it in the first
54 that the core belongs to (in fact, it may apply to an entire hierarchy of larger
55 units containing the core). Namely, if all of the cores in the larger unit
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
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
66 multiple individual single-core "processors", referred to as *hardware threads*
67 (or hyper-threads specifically on Intel hardware), that each can follow one
68 sequence of instructions. Then, the hardware threads are CPUs from the CPU idle
70 by one of them, the hardware thread (or CPU) that asked for it is stopped, but
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
78 ---------
84 Tasks are the CPU scheduler's representation of work. Each task consists of a
87 processor every time the task's code is run by a CPU. The CPU scheduler
91 no specific conditions preventing their code from being run by a CPU as long as
92 there is a CPU available for that (for example, they are not waiting for any
93 events to occur or similar). When a task becomes runnable, the CPU scheduler
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
102 assigned to the given CPU and the CPU is then regarded as idle. In other words,
108 available idle states from being used, the CPU will simply execute more or less
112 .. _idle-loop:
118 calls into a code module referred to as the *governor* that belongs to the CPU
120 the CPU to ask the hardware to enter. Second, it invokes another code module
127 the platform or the processor architecture and organized in a one-dimensional
134 taken into account by the governor, the *target residency* and the (worst-case)
140 latency, in turn, is the maximum time it will take a CPU asking the processor
151 CPU depends on can spend in an idle state, including the time necessary to enter
152 and exit it. However, the CPU may be woken up by a non-timer event at any time
154 when that may happen. The governor can only see how much time the CPU actually
162 There are four ``CPUIdle`` governors available, ``menu``, `TEO <teo-gov_>`_,
165 tick can be `stopped by the idle loop <idle-cpus-and-tick_>`_. Available
169 :file:`current_governor` file under :file:`/sys/devices/system/cpu/cpuidle/`
183 file under :file:`/sys/devices/system/cpu/cpuidle/` in ``sysfs``.
186 .. _idle-cpus-and-tick:
192 the time sharing strategy of the CPU scheduler. Of course, if there are
193 multiple runnable tasks assigned to one CPU at the same time, the only way to
195 share the available CPU time. Namely, in rough approximation, each task is
196 given a slice of the CPU time to run its code, subject to the scheduling class,
197 prioritization and so on and when that time slice is used up, the CPU should be
199 may not want to give the CPU away voluntarily, however, and the scheduler tick
203 The scheduler tick is problematic from the CPU idle time management perspective,
208 the tick period length. Moreover, in that case the idle duration of any CPU
214 "idle" one. In other words, from the CPU scheduler perspective, the only user
215 of the CPU time on them is the idle loop. Since the time of an idle CPU need
217 tick goes away if the given CPU is idle. Consequently, it is possible to stop
223 (non-tick) timer due to trigger within the tick range, stopping the tick clearly
225 reprogrammed in that case. Second, if the governor is expecting a non-timer
239 so that it does not wake up the CPU too early.
247 loop altogether. That can be done through the build-time configuration of it
255 generally regarded as more energy-efficient than the systems running kernels in
261 .. _menu-gov:
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
274 length* in what follows, is the upper bound on the time before the next CPU
279 One of them is used when tasks previously running on the given CPU are waiting
286 selecting the idle state for the CPU) is updated after the CPU has been woken
317 previously ran on the given CPU and now they are waiting for I/O operations to
319 from the power management quality of service, or `PM QoS <cpu-pm-qos_>`_,
331 if it has not decided to `stop the scheduler tick <idle-cpus-and-tick_>`_. That
340 .. _teo-gov:
347 <menu-gov_>`_: it always tries to find the deepest idle state suitable for the
350 .. kernel-doc:: drivers/cpuidle/governors/teo.c
351 :doc: teo-description
353 .. _idle-states-representation:
358 For the CPU idle time management purposes all of the physical idle states
359 supported by the processor have to be represented as a one-dimensional array of
360 |struct cpuidle_state| objects each allowing an individual (logical) CPU to ask
365 of it <idle-loop_>`_, must reflect the properties of the idle state at the
371 (say "X") at the "core" level by one core will trigger the module to try to
372 enter a specific idle state of its own (say "MX") if the other core is in idle
373 state "X" already. In other words, asking for idle state "X" at the "core"
375 "module" level, but there is no guarantee that this is going to happen (the core
380 time the CPU needs to be idle to save any energy in case the hardware enters
383 because that is the maximum delay between a wakeup signal and the time the CPU
390 state at the "core" level does not automatically affect the "module" level, for
408 For each CPU in the system, there is a :file:`/sys/devices/system/cpu/cpu<N>/cpuidle/`
410 CPU at the initialization time. That directory contains a set of subdirectories
412 objects defined for the given CPU minus one. Each of these directories
451 Total time spent in this idle state by the given CPU (as measured by the
455 Total number of times the hardware has been asked by the given CPU to
460 CPU was rejected.
468 given idle state is disabled for this particular CPU, which means that the
469 governor will never select it for this particular CPU and the ``CPUIdle``
470 driver will never ask the hardware to enter it for that CPU as a result.
471 However, disabling an idle state for one CPU does not prevent it from being
478 this particular CPU, but it still may be disabled for some or all of the other
480 be disabled for this particular CPU and writing 0 to it allows the governor to
481 take it into consideration for the given CPU and the driver to ask for it,
493 really spent by the given CPU in the given idle state, because it is measured by
497 asking the hardware to enter an idle state and the subsequent wakeup of the CPU
512 .. _cpu-pm-qos:
519 energy-efficiency features of the kernel to prevent performance from dropping
522 CPU idle time management can be affected by PM QoS in two ways, through the
523 global CPU latency limit and through the resume latency constraints for
528 signed 32-bit integer) to it. In turn, the resume latency constraint for a CPU
530 32-bit integer) to the :file:`power/pm_qos_resume_latency_us` file under
531 :file:`/sys/devices/system/cpu/cpu<N>/` in ``sysfs``, where the CPU number
540 global CPU latency limit and for each individual CPU, aggregates them and
545 PM QoS request to be created and added to a global priority list of CPU latency
551 that effective value will be set as a new CPU latency limit. Thus requesting a
563 with that file descriptor to be removed from the global priority list of CPU
568 In turn, for each CPU there is one resume latency PM QoS request associated with
570 :file:`/sys/devices/system/cpu/cpu<N>/` in ``sysfs`` and writing to it causes
575 practice is to pin a process to the CPU in question and let it use the
579 CPU in question every time the list of requests is updated this way or another
582 CPU idle time governors are expected to regard the minimum of the global
583 (effective) CPU latency limit and the effective resume latency constraint for
584 the given CPU as the upper limit for the exit latency of the idle states that
585 they are allowed to select for that CPU. They should never select any idle
593 `disabled for individual CPUs <idle-states-representation_>`_, there are kernel
594 command line parameters affecting CPU idle time management.
597 CPU idle time management entirely. It does not prevent the idle loop from
598 running on idle CPUs, but it prevents the CPU idle time governors and drivers
600 will ask the hardware to enter idle states on idle CPUs via the CPU architecture
603 processors implementing the architecture (i.e. CPU instruction set) in question,
604 however, so it is rather crude and not very energy-efficient. For this reason,
614 The other kernel command line parameters controlling CPU idle time management
619 options related to CPU idle time management: ``idle=poll``, ``idle=halt``,
633 P-states (see |cpufreq|) that require any number of CPUs in a package to be
634 idle, so it very well may hurt single-thread computations performance as well as
635 energy-efficiency. Thus using it for performance reasons may not be a good idea
639 the CPU to enter idle states. When this option is used, the ``acpi_idle``
646 In addition to the architecture-level kernel command line options affecting CPU
652 `Representation of Idle States <idle-states-representation_>`_), causes the