Skip to content

How do I attach bpf programs to perf events? #800

Answered by florianl
Jun10ng asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Jun10ng

In general ebpf and perf are two very different subsystem of the Linux Kernel. And as far as I can tell, libbpf only provides a very limited part of the perf subsystem to use with ebpf.

If you check out github.com/cilium/ebpf/link you will notice, the package link make use of perf elements for its use in Tracepoints and Kprobes. This approaches are event based. So your eBPF program will only be triggered if the tracepoint or kprobe is used.

A different part of the perf subsystem is based on sampling. And I think you might look for a solution in this space. Implementing a more wider spectrum of the perf Kernel subsystem in Go is quite complex. But there are packages like github…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ti-mo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants