This set introduces bpftool prog profile command, which uses hardware counters to profile BPF programs. This command attaches fentry/fexit programs to a target program. These two programs read hardware counters before and after the target program and calculate the difference. Sending as RFC because 2/4 will be replaced by Eelco Chaudron's work for bpf_program__set_attach_target(). Please share your comments. Thanks, Song Song Liu (4): bpf: allow bpf_perf_event_read_value in all BPF programs libbpf: introduce bpf_program__overwrite_section_name() bpftool: introduce "prog profile" command bpftool: Documentation for bpftool prog profile kernel/trace/bpf_trace.c | 4 +- .../bpftool/Documentation/bpftool-prog.rst | 17 + tools/bpf/bpftool/profiler.skel.h | 820 ++++++++++++++++++ tools/bpf/bpftool/prog.c | 387 ++++++++- tools/bpf/bpftool/skeleton/README | 3 + tools/bpf/bpftool/skeleton/profiler.bpf.c | 185 ++++ tools/bpf/bpftool/skeleton/profiler.h | 47 + tools/lib/bpf/libbpf.c | 13 +- tools/lib/bpf/libbpf.h | 4 + tools/lib/bpf/libbpf.map | 5 + 10 files changed, 1481 insertions(+), 4 deletions(-) create mode 100644 tools/bpf/bpftool/profiler.skel.h create mode 100644 tools/bpf/bpftool/skeleton/README create mode 100644 tools/bpf/bpftool/skeleton/profiler.bpf.c create mode 100644 tools/bpf/bpftool/skeleton/profiler.h -- 2.17.1