bcc: Missing documentation for attach_perf_event and open_perf_event

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))

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 4
  • Comments: 36 (3 by maintainers)

Most upvoted comments

Thanks @cippaciong for pointing out missed documentation. I think they are an important part of usability for BCC. I added a lot of the Perf Event related logic and was just a bit lazy on writing reference guide. I will try to work on adding them as well