On Mon, Feb 17, 2020 at 7:06 PM Daniel Xu <dxu@xxxxxxxxx> wrote: > > Add a selftest to test: > > * default bpf_read_branch_records() behavior > * BPF_F_GET_BRANCH_RECORDS_SIZE flag behavior > * error path on non branch record perf events > * using helper to write to stack > * using helper to write to global > > On host with hardware counter support: > > # ./test_progs -t perf_branches > #27/1 perf_branches_hw:OK > #27/2 perf_branches_no_hw:OK > #27 perf_branches:OK > Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED > > On host without hardware counter support (VM): > > # ./test_progs -t perf_branches > #27/1 perf_branches_hw:OK > #27/2 perf_branches_no_hw:OK > #27 perf_branches:OK > Summary: 1/2 PASSED, 1 SKIPPED, 0 FAILED > > Also sync tools/include/uapi/linux/bpf.h. > > Signed-off-by: Daniel Xu <dxu@xxxxxxxxx> > --- LGTM. Acked-by: Andrii Nakryiko <andriin@xxxxxx> > tools/include/uapi/linux/bpf.h | 25 ++- > .../selftests/bpf/prog_tests/perf_branches.c | 169 ++++++++++++++++++ > .../selftests/bpf/progs/test_perf_branches.c | 50 ++++++ > 3 files changed, 243 insertions(+), 1 deletion(-) > create mode 100644 tools/testing/selftests/bpf/prog_tests/perf_branches.c > create mode 100644 tools/testing/selftests/bpf/progs/test_perf_branches.c > [...]