Profiling
Use bpftool to profile BPF programs for performance
It is possible to profile eBPF… with eBPF! Recent bpftool versions can attach programs (of types “fentry” or “fexit”) to the entry or exit of other eBPF programs and use perf events to collect statistics on them.
# bpftool prog profile <prog> <metrics>
This screenshot is from the man page.
This requires that the kernel running on the system has been compiled with BTF information, and bpftool with the use of a “skeleton”.
Here is another example, featuring two metrics that were more recently added: ITLB and DTLB misses for a running eBPF program (Instruction/Data Translation Lookaside Buffer.
# bpftool prog profile <prog> itlb_misses dtlb_misses