Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 1.62 KB

File metadata and controls

35 lines (23 loc) · 1.62 KB
title Libbpf userspace function 'perf_buffer__buffer'
description This page documents the 'perf_buffer__buffer' libbpf userspace function, including its definition, usage, and examples.

Libbpf userspace function perf_buffer__buffer

:octicons-tag-24: 1.0.0

Returns the per-CPU raw mmap'ed underlying memory region of the ring buffer.

Definition

#!c int perf_buffer__buffer(struct perf_buffer *pb, int buf_idx, void **buf, size_t *buf_size);

Parameters

  • pb: the perf buffer structure
  • buf_idx: the buffer index to retrieve
  • buf: (out) gets the base pointer of the mmap'ed memory
  • buf_size: (out) gets the size of the mmap'ed region

Return

0 on success, negative error code for failure

Usage

This ring buffer can be used to implement a custom events consumer. The ring buffer starts with the struct perf_event_mmap_page, which holds the ring buffer management fields, when accessing the header structure it's important to be SMP aware. You can refer to perf_event_read_simple for a simple example.

Example

!!! example "Docs could be improved" This part of the docs is incomplete, contributions are very welcome