Skip to content

gobpf: Please make perf ring buffer size configurable #156

Open
@somersf

Description

As per iovisor/bcc#997 but for the Go API.

In bcc/perf.go, a page count parameter can't be supplied; it uses an fixed constant size.

const BPF_PERF_READER_PAGE_CNT = 8
...

func bpfOpenPerfBuffer(cpu uint, callbackDataIndex uint64) (unsafe.Pointer, error) {
	cpuC := C.int(cpu)
	reader, err := C.bpf_open_perf_buffer(
		(C.perf_reader_raw_cb)(unsafe.Pointer(C.callback_to_go)),
		nil,
		unsafe.Pointer(uintptr(callbackDataIndex)),
		-1, cpuC, BPF_PERF_READER_PAGE_CNT)
	if reader == nil {
		return nil, fmt.Errorf("failed to open perf buffer: %v", err)
	}
	return reader, nil
}

Thanks.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions