DPDK 25.07.0
Data Structures | Macros | Functions | Variables
rte_pmu.h File Reference
#include <linux/perf_event.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_common.h>
#include <rte_compat.h>
#include <rte_lcore.h>

Go to the source code of this file.

Data Structures

struct  rte_pmu_event_group
 
struct  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

This file defines generic API and types necessary to setup PMU and read selected counters in runtime. Exported functions are generally not MT-safe. One exception is rte_pmu_read() which can be called concurrently once everything has been setup.

In order to initialize the library, following sequence of calls performed by the same EAL thread is required:

rte_pmu_init() rte_pmu_add_event()

Afterwards all threads can read events by calling rte_pmu_read().

Definition in file rte_pmu.h.

Macro Definition Documentation

◆ RTE_MAX_NUM_GROUP_EVENTS

#define RTE_MAX_NUM_GROUP_EVENTS   8

Maximum number of events in a group.

Definition at line 50 of file rte_pmu.h.

Function Documentation

◆ __rte_pmu_read_userpage()

static __rte_experimental __rte_always_inline uint64_t __rte_pmu_read_userpage ( struct perf_event_mmap_page *  pc)
static
Warning
EXPERIMENTAL: this API may change without prior notice.

Read PMU counter.

Warning
This should not be called directly.
Parameters
pcPointer to the mmapped user page.
Returns
Counter value read from hardware.

Definition at line 97 of file rte_pmu.h.

◆ __rte_pmu_enable_group()

__rte_experimental int __rte_pmu_enable_group ( struct rte_pmu_event_group group)
Warning
EXPERIMENTAL: this API may change without prior notice.

Enable group of events on the calling lcore.

Warning
This should not be called directly.
Parameters
groupPointer to the group which will be enabled.
Returns
0 in case of success, negative value otherwise.

◆ rte_pmu_init()

__rte_experimental int rte_pmu_init ( void  )
Warning
EXPERIMENTAL: this API may change without prior notice.

Initialize PMU library.

Returns
0 in case of success, negative value otherwise.

◆ rte_pmu_fini()

__rte_experimental void rte_pmu_fini ( void  )
Warning
EXPERIMENTAL: this API may change without prior notice.

Finalize PMU library.

◆ rte_pmu_add_event()

__rte_experimental int rte_pmu_add_event ( const char *  name)
Warning
EXPERIMENTAL: this API may change without prior notice.

Add event to the group of enabled events.

Parameters
nameName 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_pmu_read()

static __rte_experimental __rte_always_inline uint64_t rte_pmu_read ( unsigned int  index)
static
Warning
EXPERIMENTAL: this API may change without prior notice.

Read hardware counter configured to count occurrences of an event.

This is called by an lcore (EAL thread) bound exclusively to particular CPU and may not work as expected if gets migrated elsewhere. Reason being event group is pinned hence not supposed to be multiplexed with any other events. This is the only API which can be called concurrently by different lcores.

Parameters
indexIndex of an event to be read.
Returns
Event value read from register. In case of errors or lack of support, 0 is returned. In other words, stream of zeros in a trace file indicates problem with reading particular PMU event register.

Definition at line 212 of file rte_pmu.h.

Variable Documentation

◆ rte_pmu

struct rte_pmu rte_pmu
extern

PMU state container.