This series of patches is an approach to integrate eBPF with perf.
After applying these patches, users are allowed to use following
command to load eBPF program compiled by LLVM into kernel:
$ perf bpf sample_bpf.o
The required BPF code and the loading procedure is similar to Alexei
Starovoitov's libbpf in sample/bpf, with following exceptions:
1. The section name are not required leading with 'kprobe/' or
'kretprobe/'. Without such leading, any valid C var name can be use.
2. A 'config' section can be provided to describe the position and
arguments of a program. Syntax is identical to 'perf probe'.
An example is pasted at the bottom of this cover letter. In that
example, mybpfprog is configured by string in config section, and will
be probed at __alloc_pages_nodemask. sample_bpf.o is generated using:
$ $CLANG -I/usr/src/kernel/include -I/usr/src/kernel/usr/include -D__KERNEL__ \
-Wno-unused-value -Wno-pointer-sign \
-O2 -emit-llvm -c sample_bpf.c -o -| $LLC -march=bpf -filetype=obj -o \
sample_bpf.o
And can be loaded using:
$ perf bpf sample_bpf.o
This series is only a limited functional. Following works are on the
todo list:
1. Unprobe kprobe stubs used by eBPF programs when unloading;
2. Enable eBPF programs to access local variables and arguments
by utilizing debuginfo;
3. Output data in perf way.
In this series:
Patch 1/22 is a bugfix in perf probe, and may be triggered by following
patches;
Patch 2-3/22 are preparation, add required macros and syscall
definition into perf source tree.
Patch 4/22 add 'perf bpf' command.
Patch 5-20/22 are labor works, which parse the ELF object file, collect
information in object files, create maps needed by programs, link map
and programs, config programs and load programs into kernel.
Patch 21-22/22 are the final work. Patch 21 creates kprobe points which
will be used by eBPF programs, patch 22 creates perf file descriptors
then attach eBPF programs on them.