iovisor / iovisor/bcc

Missing documentation for attach_perf_event and open_perf_event

Open
#1,756 36 comments 4 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
5d 13h
Merged PRs (30d)
3

Description

Hello, in these days I've been playing around with perf events for a project I've been working on. While I successfully managed to get things working, mainly looking at code examples like `tools/profile.py`, it occurred to me that there is very little documentation about `attach_perf_event` and `open_perf_event`.
The `attach_perf_event` function seems to be completely undocumented, I can't find any mention of it in the reference guide, while `open_perf_event` is mentioned just once in a more general example about `BPF_PERF_ARRAY`.

It would be nice to add a few lines to explain how to use those helpers, maybe providing some examples showing different ways to interact with them, e.g.:
```
b["cpu_cycles"].open_perf_event(b["cpu_cycles"].HW_CPU_CYCLES)
b["cpu_cycles"].open_perf_event(PerfType.HARDWARE, PerfHWConfig.CPU_CYCLES)
b["cpu_cycles"].open_perf_event(4, int("73003c",16))
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with tools/profile.py to understand the existing open_perf_event usage, then inspect the reference guide for the missing attach_perf_event entry and the current BPF_PERF_ARRAY example. Add concise documentation for both helpers, including the interaction patterns shown in the issue, and verify that the examples match the existing API.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.