rte_pmu.h(3)
π NAME π
rte_pmu.h β bestie, this is the header that runs the whole Performance Monitoring Unit situation in DPDK. It's a library functions manual page, and we are gonna get into it. π
β¨ SYNOPSIS β¨
First, the includes, no cap, exactly these:
#include <linux/perf_event.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_common.h>
#include <rte_compat.h>
#include <rte_debug.h>
#include <rte_lcore.h>
π§Έ Data Structures
struct rte_pmu_event_groupstruct rte_pmu
π§Έ Macros
#define RTE_MAX_NUM_GROUP_EVENTS 8
π§Έ Functions
static __rte_experimental __rte_always_inline uint64_t
__rte_pmu_read_userpage (struct perf_event_mmap_page *pc)
__rte_experimental int __rte_pmu_enable_group (struct
rte_pmu_event_group *group)
__rte_experimental int rte_pmu_init (void)
__rte_experimental void rte_pmu_fini (void)
__rte_experimental int rte_pmu_add_event (const char *name)
static __rte_experimental __rte_always_inline uint64_t rte_pmu_read
(unsigned int index)
π§Έ Variables
struct rte_pmu rte_pmu
πΈ Detailed Description πΈ
Performance Monitoring Unit (PMU) event tracing operations π
So like, what is this file even doing? It defines the generic API and types you need to set up PMU and read selected counters at runtime. And here's the tea: the exported functions are generally not MT-safe. The one glow-up exception is rte_pmu_read(), which is totally fine to call concurrently once everything has been set up. β¨
To initialize the library, you need this exact sequence of calls, and they all have to be performed by the same EAL thread:
rte_pmu_init() rte_pmu_add_event()
Afterwards all threads can read events by calling rte_pmu_read(). Slay. π
Definition in file rte_pmu.h.
π Macro Definition Documentation π
#define RTE_MAX_NUM_GROUP_EVENTS 8
Maximum number of events in a group. That's it, that's the whole vibe β 8, periodt. π¦
Definition at line 48 of file rte_pmu.h.
π Function Documentation π
__rte_experimental __rte_always_inline uint64_t __rte_pmu_read_userpage (struct perf_event_mmap_page * pc) [static]
β οΈ EXPERIMENTAL: this API may change without prior notice.
Read PMU counter. π«Ά
π¨ This should not be called directly. Bestie, do NOT just ring it up. It's not for you, it's an internal situation.
Parameters
pcβ Pointer to the mmapped user page.
Returns
- Counter value read from hardware.
Definition at line 95 of file rte_pmu.h.
__rte_experimental int __rte_pmu_enable_group (struct rte_pmu_event_group * group)
β οΈ EXPERIMENTAL: this API may change without prior notice.
Enable group of events on the calling lcore. π«
π¨ This should not be called directly. Same energy as above β hands off, it's internal.
Parameters
groupβ Pointer to the group which will be enabled.
Returns
0in case of success, negative value otherwise.
__rte_experimental int rte_pmu_init (void )
β οΈ EXPERIMENTAL: this API may change without prior notice.
Initialize PMU library. The opening act. π¬
Returns
0in case of success, negative value otherwise.
__rte_experimental void rte_pmu_fini (void )
β οΈ EXPERIMENTAL: this API may change without prior notice.
Finalize PMU library. Closing time, pack it up. π§Ή
__rte_experimental int rte_pmu_add_event (const char * name)
β οΈ EXPERIMENTAL: this API may change without prior notice.
Add event to the group of enabled events. β¨
Parameters
nameβ Name of an event listed under/sys/bus/event_source/devices/pmu/events, where PMU is a placeholder for an event source.
Returns
- Event index in case of success, negative value otherwise.
__rte_experimental __rte_always_inline uint64_t rte_pmu_read (unsigned int index) [static]
β οΈ EXPERIMENTAL: this API may change without prior notice.
Read hardware counter configured to count occurrences of an event. π₯
Okay this one's important so listen up: this is called by an lcore (EAL thread) bound exclusively to particular CPU and may not work as expected if it gets migrated elsewhere. The reason being, the event group is pinned hence not supposed to be multiplexed with any other events. Also!! This is the only API which can be called concurrently by different lcores. Main character behavior, honestly. π
Parameters
indexβ Index of an event to be read.
Returns
- Event value read from register. In case of errors or lack of support,
0is returned. In other words, stream of zeros in a trace file indicates problem with reading particular PMU event register. π
Definition at line 204 of file rte_pmu.h.
π¦ Variable Documentation π¦
struct rte_pmu rte_pmu [extern]
PMU state container. It holds the state. That's the job. π
β Author β
Generated automatically by Doxygen for DPDK from the source code. (Not a human, just a robot doing its little thing. Respect. π€)
And that's the whole page, bestie!! This fine piece of documentation came to you courtesy of DPDK, Version 25.11.3, filed under rte_pmu.h(3) β go read some counters and hydrate. πβ¨ππ«Ά
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms