Skip to content

Commit 1cce3b6

Browse files
mattbobrowskiKernel Patches Daemon
authored andcommitted
selftests/bpf: skip test_perf_branches_hw() on unsupported platforms
Gracefully skip the test_perf_branches_hw subtest on platforms that do not support LBR or require specialized perf event attributes to enable branch sampling. For example, AMD's Milan (Zen 3) supports BRS rather than traditional LBR. This requires specific configurations (attr.type = PERF_TYPE_RAW, attr.config = RETIRED_TAKEN_BRANCH_INSTRUCTIONS) that differ from the generic setup used within this test. Notably, it also probably doesn't hold much value to special case perf event configurations for selected micro architectures. Fixes: 67306f8 ("selftests/bpf: Add bpf_read_branch_records() selftest") Signed-off-by: Matt Bobrowski <[email protected]>
1 parent 729c7ba commit 1cce3b6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/testing/selftests/bpf/prog_tests/perf_branches.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ static void test_perf_branches_hw(void)
116116
pfd = syscall(__NR_perf_event_open, &attr, -1, 0, -1, PERF_FLAG_FD_CLOEXEC);
117117

118118
/*
119-
* Some setups don't support branch records (virtual machines, !x86),
120-
* so skip test in this case.
119+
* Some setups don't support LBR (virtual machines, !x86, AMD Milan Zen
120+
* 3 which only supports BRS), so skip test in this case.
121121
*/
122122
if (pfd < 0) {
123-
if (errno == ENOENT || errno == EOPNOTSUPP) {
123+
if (errno == ENOENT || errno == EOPNOTSUPP || errno == EINVAL) {
124124
printf("%s:SKIP:no PERF_SAMPLE_BRANCH_STACK\n",
125125
__func__);
126126
test__skip();

0 commit comments

Comments
 (0)