Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Use PERF_COUNT_HW_CPU_CYCLES event for get_branch_snapshot

perf_event with type=PERF_TYPE_RAW and config=0x1b00 turned out to be not
reliable in ensuring LBR is active. Thus, test_progs:get_branch_snapshot is
not reliable in some systems. Replace it with PERF_COUNT_HW_CPU_CYCLES
event, which gives more consistent results.

Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20230407190130.2093736-1-song@kernel.org

authored by

Song Liu and committed by
Andrii Nakryiko
3ebf5212 f3f21349

+2 -2
+2 -2
tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
··· 37 37 38 38 /* create perf event */ 39 39 attr.size = sizeof(attr); 40 - attr.type = PERF_TYPE_RAW; 41 - attr.config = 0x1b00; 40 + attr.type = PERF_TYPE_HARDWARE; 41 + attr.config = PERF_COUNT_HW_CPU_CYCLES; 42 42 attr.sample_type = PERF_SAMPLE_BRANCH_STACK; 43 43 attr.branch_sample_type = PERF_SAMPLE_BRANCH_KERNEL | 44 44 PERF_SAMPLE_BRANCH_USER | PERF_SAMPLE_BRANCH_ANY;