class IdlePowerThread
Defined at line 47 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
Platform Independent Per-CPU Idle/Power Thread
Manages the idle, suspend, and offline functions of a CPU. This thread is scheduled whenever
there is no eligible work in the run queues of a CPU or a power state management operation is
requested for the CPU. The idle/power thread provides the platform-independent run loop for
handling these functions and delegates to the platform-specific subsystems for the relevant
operations.
Public Methods
void IdlePowerThread ()
Defined at line 49 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
void ~IdlePowerThread ()
Defined at line 50 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
void IdlePowerThread (const IdlePowerThread & )
Defined at line 52 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
IdlePowerThread & operator= (const IdlePowerThread & )
Defined at line 53 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
void IdlePowerThread (IdlePowerThread && )
Defined at line 54 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
IdlePowerThread & operator= (IdlePowerThread && )
Defined at line 55 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
PendingPowerWorkPredicate pending_power_work ()
Returns true if the power thread should be scheduled instead of eligible work because it needs
to perform a transition or power management function.
Defined at line 93 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
TransitionResult TransitionOfflineToActive (zx_instant_mono_t timeout_at)
Requests to transition from Offline to Active.
Returns:
- {ZX_OK, Offline} if the transition was successful.
- {ZX_OK, Active} if the current state was already Active.
- {ZX_ERR_BAD_STATE, current state} if the current state was not Active or Offline.
- {ZX_ERR_TIMED_OUT, Offline} if the current state was Offline and transition timeout
expired.
Defined at line 136 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
TransitionResult TransitionActiveToOffline (zx_instant_mono_t timeout_at)
Requests to transition from Active to Offline.
After the transition completes, waits until the platform reports (via platform_get_cpu_state)
that the CPU is powered off or stopped. If the platform does not support querying CPU power
state, this wait is skipped. If the platform never reports that the CPU is powered off, this
waits until |timeout_at| (i.e. indefinitely, if |timeout_at| is ZX_TIME_INFINITE), logging a
message periodically.
Returns:
- {ZX_OK, Active} if the transition was successful.
- {ZX_OK, Offline} if the current state was already Offline.
- {ZX_ERR_BAD_STATE, current state} if the current state was not Active or Offline.
- {ZX_ERR_TIMED_OUT, Active} if the current state was Active and transition timeout expired.
Note that in this case the request is not withdrawn (once the CPU's idle/power thread has
begun to take it offline, it cannot be stopped), so the CPU may still go Offline later.
- {ZX_ERR_TIMED_OUT, starting state} if the transition completed, but the timeout expired
before the platform reported that the CPU was powered off. Note that in this case, the
CPU's state is Offline.
- {error, starting state} if the transition completed, but querying the CPU's power state
failed with |error|. Note that in this case, the CPU's state is Offline.
Defined at line 328 of file ../../zircon/kernel/kernel/idle_power_thread.cc
zx_instant_boot_t TransitionAllActiveToSuspend (zx_instant_boot_t resume_at)
Attempts to transition all active CPUs from Active to Suspend until the specified resume time.
CPUs that are Offline before suspend will remain Offline after resume until explicitly
transitioned to Active.
Returns: The boot-time at which the suspend operation is formally considered to have started.
This value can be used in conjunction with timestamps recorded in wake events to decide whether
a wake vector became signaled before suspend had formally started, or not.
Defined at line 416 of file ../../zircon/kernel/kernel/idle_power_thread.cc
zx_instant_boot_t SuspendSystem (zx_instant_boot_t resume_at)
Attempts to suspend the entire system using platform_suspend_system until the specified resume
time.
Similar to |TransitionAllActiveToSuspend|, except that rather than transitioning the active
non-boot CPUs to Suspend, transitions them to Offline (powering them off). Once the platform
has confirmed that every one of them has powered off, the boot CPU is transitioned to Suspend
and its idle/power thread suspends the system with platform_suspend_system. If power off
cannot be confirmed for every CPU, the suspend operation is aborted. Upon resume, the non-boot
CPUs which were taken offline are brought back online. (If bringing a CPU back online fails,
a KERNEL_OOPS is logged and that CPU remains Offline until explicitly transitioned to Active.
Its timers are migrated to the boot CPU, but its queued DPCs and pinned threads remain with it
until it is brought back online.)
CPUs that are Offline before suspend will remain Offline after resume until explicitly
transitioned to Active.
If the platform does not support system suspend, or cannot report CPU power state (see
platform_get_cpu_state), this behaves like |TransitionAllActiveToSuspend|.
Returns: The boot-time at which the suspend operation is formally considered to have started.
This value can be used in conjunction with timestamps recorded in wake events to decide whether
a wake vector became signaled before suspend had formally started, or not.
Defined at line 420 of file ../../zircon/kernel/kernel/idle_power_thread.cc
int Run (void * arg)
Implements the run loop executed by the CPU's idle/power thread.
Defined at line 177 of file ../../zircon/kernel/kernel/idle_power_thread.cc
void InitHook (uint level)
Defined at line 781 of file ../../zircon/kernel/kernel/idle_power_thread.cc
void FlushAndHalt ()
Called by mp_unplug_current_cpu() to complete last steps of taking the CPU offline.
Defined at line 167 of file ../../zircon/kernel/kernel/idle_power_thread.cc
Thread & thread ()
Accessors to the underlying Thread instance.
Defined at line 183 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
const Thread & thread ()
Defined at line 184 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
bool system_suspended ()
Accessor to the global system suspend state.
Defined at line 187 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
uint64_t pending_wake_events ()
Defined at line 190 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
Enumerations
enum class State : uint8_t
| Name | Value | Comments |
|---|---|---|
| Active | 0 | -- |
| Wakeup | 1 |
Similar to Active with respect to scheduling but signals a wakeup occurred. |
| Offline | 2 | -- |
| Suspend | 3 | -- |
The current or target high-level operational state of the CPU. The depth and type of
idle/suspend states depends inputs from other subsystems, such as timer and run queues and
system power targets.
TODO(https://fxbug.dev/42086705): Rationalize this state with mp active / online states.
Defined at line 61 of file ../../zircon/kernel/include/kernel/idle_power_thread.h
Records
Friends
void IdlePowerThread ()
WakeResult IdlePowerThread ()
class WakeEvent
class IdlePowerThreadTestAccess
class Scheduler
class percpu