Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(bcc/module.go): document attachperfevent arguments #327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion bcc/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,22 @@ func (bpf *Module) AttachRawTracepoint(name string, fd int) error {
return nil
}

// AttachPerfEvent attaches a perf event fd to a function
// AttachPerfEvent attaches a perf event fd to a function.
// Argument 'evType' is a member of 'perf_type_id' enum in the kernel
// header 'include/uapi/linux/perf_event.h'. Argument 'evConfig'
// is one of PERF_COUNT_* constants in the same file.
//
// Arguments 'samplePeriod' and 'sampleFreq' are mutually exclusive.
// A sampling event is one that generates an overflow notification every N events,
// where N is given by samplePeriod.
// Argument 'sampleFreq' can be used if you wish to use frequency rather than period.
// The kernel will adjust the sampling period to try and achieve the desired rate.
//
// Arguments 'pid' and 'cpu' specify which process and CPU to monitor.
//
// Argument 'groupFd' allows event groups to be created. An event group has one event which
// is the group leader. A single event is considered a group with only 1 member with
// groupFd = -1. Argument 'fd' is the program fd.
func (bpf *Module) AttachPerfEvent(evType, evConfig int, samplePeriod int, sampleFreq int, pid, cpu, groupFd, fd int) error {
key := fmt.Sprintf("%d:%d", evType, evConfig)
if _, ok := bpf.perfEvents[key]; ok {
Expand Down