Node_Exporter/vendor/github.com/hodgesds/perf-utils/bpf.go
Daniel Hodges 7882009870 Add perf exporter (#1274)
Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
2019-05-07 13:21:41 +02:00

23 lines
588 B
Go

// +build linux
package perf
import (
"golang.org/x/sys/unix"
)
// BPFProfiler is a Profiler that allows attaching a Berkeley
// Packet Filter (BPF) program to an existing kprobe tracepoint event.
// You need CAP_SYS_ADMIN privileges to use this interface. See:
// https://lwn.net/Articles/683504/
type BPFProfiler interface {
Profiler
AttachBPF(int) error
}
// AttachBPF is used to attach a BPF program to a profiler by using the file
// descriptor of the BPF program.
func (p *profiler) AttachBPF(fd int) error {
return unix.IoctlSetInt(p.fd, unix.PERF_EVENT_IOC_SET_BPF, fd)
}