]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: skip test_perf_branches_hw() on unsupported platforms
authorMatt Bobrowski <mattbobrowski@google.com>
Thu, 20 Nov 2025 14:20:59 +0000 (14:20 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 22 Nov 2025 00:47:58 +0000 (16:47 -0800)
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: 67306f84ca78c ("selftests/bpf: Add bpf_read_branch_records() selftest")
Signed-off-by: Matt Bobrowski <mattbobrowski@google.com>
Acked-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20251120142059.2836181-1-mattbobrowski@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/perf_branches.c

index bc24f83339d6429723b8d7f47666e091dd70ad87..06c7986131d96fb5bc81783399d944d84881bc82 100644 (file)
@@ -116,11 +116,11 @@ static void test_perf_branches_hw(void)
        pfd = syscall(__NR_perf_event_open, &attr, -1, 0, -1, PERF_FLAG_FD_CLOEXEC);
 
        /*
-        * Some setups don't support branch records (virtual machines, !x86),
-        * so skip test in this case.
+        * Some setups don't support LBR (virtual machines, !x86, AMD Milan Zen
+        * 3 which only supports BRS), so skip test in this case.
         */
        if (pfd < 0) {
-               if (errno == ENOENT || errno == EOPNOTSUPP) {
+               if (errno == ENOENT || errno == EOPNOTSUPP || errno == EINVAL) {
                        printf("%s:SKIP:no PERF_SAMPLE_BRANCH_STACK\n",
                               __func__);
                        test__skip();