|
Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
|
Data Structures | |
| struct | perf_counter_config |
| Performance counter configuration entry. More... | |
Functions | |
| int | perf_counter_init (void) |
| Initialize the PMU for the current logical CPU. | |
| uint32_t | perf_counter_num_counters (void) |
| void | perf_counter_get_info (perf_counter_info_t *info) |
| Fill info with PMU identification for the current logical CPU. | |
| int | perf_counter_config (uint32_t counter, perf_counter_evt_t event) |
| Map hardware event counter counter to architectural event event. | |
| void | perf_counter_enable (uint32_t counter) |
| Enable counting on hardware event counter counter. | |
| void | perf_counter_disable (uint32_t counter) |
| Disable counting on hardware event counter counter. | |
| void | perf_counter_enable_all (void) |
| Enable all implemented event counters (and the cycle counter where applicable). | |
| void | perf_counter_disable_all (void) |
| Disable all event counters (and the cycle counter where applicable). | |
| uint64_t | perf_counter_read (uint32_t counter) |
| Read the current value of hardware event counter counter. | |
| void | perf_counter_reset (uint32_t counter) |
| Reset hardware event counter counter to zero. | |
| void | perf_counter_reset_all (void) |
| Reset all hardware event counters to zero (implementation-defined; may include cycle counter policies). | |
| uint64_t | perf_counter_cycle_count (void) |
| Read the architectural cycle count register (if implemented). | |
| void | perf_counter_cycle_reset (void) |
| Reset the cycle count register to zero (implementation-defined). | |
| void | perf_counter_start (void) |
| Start counting: enable the PMU globally (implementation-defined). | |
| void | perf_counter_stop (void) |
| Stop counting: disable the PMU globally (implementation-defined). | |
| bool | perf_counter_overflow (uint32_t counter) |
| Return whether hardware event counter counter has overflowed since the flag was cleared. | |
| void | perf_counter_clear_overflow (uint32_t counter) |
| Clear the overflow flag for hardware event counter counter. | |
| void perf_counter_clear_overflow | ( | uint32_t | counter | ) |
#include <zephyr/arch/perf_counter.h>
Clear the overflow flag for hardware event counter counter.
| counter | Event counter index [0, perf_counter_num_counters()). |
| int perf_counter_config | ( | uint32_t | counter, |
| perf_counter_evt_t | event ) |
#include <zephyr/arch/perf_counter.h>
Map hardware event counter counter to architectural event event.
| counter | Event counter index in the range [0, perf_counter_num_counters()). |
| event | Event selector (perf_counter_evt_t from the architecture supplement when present). |
| uint64_t perf_counter_cycle_count | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
Read the architectural cycle count register (if implemented).
| void perf_counter_cycle_reset | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
Reset the cycle count register to zero (implementation-defined).
| void perf_counter_disable | ( | uint32_t | counter | ) |
#include <zephyr/arch/perf_counter.h>
Disable counting on hardware event counter counter.
| counter | Event counter index [0, perf_counter_num_counters()). |
| void perf_counter_disable_all | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
Disable all event counters (and the cycle counter where applicable).
| void perf_counter_enable | ( | uint32_t | counter | ) |
#include <zephyr/arch/perf_counter.h>
Enable counting on hardware event counter counter.
| counter | Event counter index [0, perf_counter_num_counters()). |
| void perf_counter_enable_all | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
Enable all implemented event counters (and the cycle counter where applicable).
| void perf_counter_get_info | ( | perf_counter_info_t * | info | ) |
#include <zephyr/arch/perf_counter.h>
Fill info with PMU identification for the current logical CPU.
info must not be NULL. Fields are only meaningful after a successful perf_counter_init on this CPU; contents are backend-defined (see arch perf_counter_info_t).
| int perf_counter_init | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
Initialize the PMU for the current logical CPU.
Architecture-neutral interface for hardware performance counters. Backends implement these functions for each supported architecture (for example ARMv8-A PMUv3 on AArch64, future ARMv8-R / Cortex-R52, RISC-V HPM CSRs, etc.).
Architectural event codes are defined by the architecture supplement (for example perf_counter_evt_t in <zephyr/arch/arm64/pmuv3.h> when CONFIG_ARM64 is enabled).
PMU is not initialized during kernel startup. Call perf_counter_init() before other perf_counter_*() functions on this CPU.
Call once per logical CPU that will use counters, before any other perf_counter_*() API on that CPU. Idempotent on success: later calls return 0 if this CPU already initialized successfully, or -ENOTSUP if this CPU recorded that no PMU is available.
PMU control and counters are per-CPU. On SMP, use the PMU only while running on the intended CPU — for example pin the thread with k_thread_cpu_pin() (requires CONFIG_SCHED_CPU_MASK), or constrain its CPU affinity with k_thread_cpu_mask_enable() / k_thread_cpu_mask_disable(), so it does not migrate during a measurement.
There is no SYS_INIT hook; callers choose when to probe (for example at the start of a benchmark).
| 0 | Success |
| -ENOTSUP | No PMU or not usable at this exception level on this CPU |
| uint32_t perf_counter_num_counters | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
#include <zephyr/arch/perf_counter.h>
Return whether hardware event counter counter has overflowed since the flag was cleared.
| counter | Event counter index [0, perf_counter_num_counters()). |
#include <zephyr/arch/perf_counter.h>
Read the current value of hardware event counter counter.
| counter | Event counter index [0, perf_counter_num_counters()). |
| void perf_counter_reset | ( | uint32_t | counter | ) |
#include <zephyr/arch/perf_counter.h>
Reset hardware event counter counter to zero.
| counter | Event counter index [0, perf_counter_num_counters()). |
| void perf_counter_reset_all | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
Reset all hardware event counters to zero (implementation-defined; may include cycle counter policies).
| void perf_counter_start | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
Start counting: enable the PMU globally (implementation-defined).
| void perf_counter_stop | ( | void | ) |
#include <zephyr/arch/perf_counter.h>
Stop counting: disable the PMU globally (implementation-defined).