|
Zephyr Project API 4.4.99
A Scalable Open Source RTOS
|
Module for monitoring CPU load. More...
Macros | |
| #define | CPU_LOAD_PERMILLE_TO_PERCENT(permille) |
| Convert a per mille CPU load value to whole percent. | |
Typedefs | |
| typedef void(* | cpu_load_cb_t) (uint8_t percent) |
Functions | |
| int | cpu_load_get_cpu (unsigned int cpu_id, bool reset) |
| Get CPU load for a specific CPU. | |
| int | cpu_load_get (bool reset) |
| Get CPU load for the current CPU. | |
| void | cpu_load_on_enter_idle (void) |
| Hook called on entering CPU idle. | |
| void | cpu_load_on_exit_idle (void) |
| Hook called on exiting CPU idle. | |
| void | cpu_load_log_control (bool enable) |
| Control periodic CPU load report. | |
| int | cpu_load_cb_reg (cpu_load_cb_t cb, uint8_t threshold_percent) |
| Optional registration of callback when load is greater or equal to the threshold. | |
| static int | cpu_load_metric_get (int cpu_id) |
| Get CPU load as a percentage for a specific CPU. | |
Module for monitoring CPU load.
The CPU load is the fraction of time the CPU spends outside of the idle state. Two measurement backends are available and selected through Kconfig:
CONFIG_CPU_LOAD_BACKEND_RUNTIME_STATSderives the load from the scheduler per-CPU runtime statistics. It is portable across architectures and supports multiple CPUs.
CONFIG_CPU_LOAD_BACKEND_IDLE_HOOKmeasures the load using the architecture idle hooks. It has lower overhead and can optionally use a hardware counter for higher precision (the counter path is single-CPU only). Available on any architecture that emits the idle hooks (
CONFIG_ARCH_HAS_CPU_IDLE_HOOKS).
Regardless of the backend, the load is reported in per mille (0...1000).
| #define CPU_LOAD_PERMILLE_TO_PERCENT | ( | permille | ) |
| typedef void(* cpu_load_cb_t) (uint8_t percent) |
#include <cpu_load.h>
| int cpu_load_cb_reg | ( | cpu_load_cb_t | cb, |
| uint8_t | threshold_percent ) |
#include <cpu_load.h>
Optional registration of callback when load is greater or equal to the threshold.
| cb | Pointer to the callback function. NULL will cancel the callback. |
| threshold_percent | Threshold [0...100]. CPU load equal or greater that this will trigger the callback. |
| 0 | - Callback registered/cancelled. |
| -EINVAL | if the threshold is invalid. |
| int cpu_load_get | ( | bool | reset | ) |
#include <cpu_load.h>
Get CPU load for the current CPU.
| reset | Reset the measurement window after reading. |
| >=0 | CPU load in per mille (0...1000). |
| <0 | Negative errno code on failure. |
#include <cpu_load.h>
Get CPU load for a specific CPU.
| cpu_id | CPU index for which to get the load. |
| reset | Reset the measurement window after reading. |
| >=0 | CPU load in per mille (0...1000). |
| <0 | Negative errno code on failure. |
| void cpu_load_log_control | ( | bool | enable | ) |
#include <cpu_load.h>
Control periodic CPU load report.
Report logging is by default enabled.
| enable | true to enable report logging and false to disable. |
|
inlinestatic |
#include <cpu_load.h>
Get CPU load as a percentage for a specific CPU.
| cpu_id | CPU index for which to get the load. |
| >=0 | CPU load in percent (0...100). |
| <0 | Negative errno code on failure. |
| void cpu_load_on_enter_idle | ( | void | ) |
#include <cpu_load.h>
Hook called on entering CPU idle.
Only used by the idle-hook backend; called from the architecture idle path.
| void cpu_load_on_exit_idle | ( | void | ) |
#include <cpu_load.h>
Hook called on exiting CPU idle.
Only used by the idle-hook backend; called from the architecture idle path.