selftests/bpf: skip test_perf_branches_hw() on unsupported platforms
Subsystems (3)
PATCH 1/1 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.
--- tools/testing/selftests/bpf/prog_tests/perf_branches.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/perf_branches.c +3 -3
@@ -128,11 +128,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 ();
Signature · 1 line
2.52.0.rc1.455.g30608eb744-goog
Quoted 12 lines · Matt Bobrowski
Gracefully skip the
test_perf_branches_hwsubtest 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.
Quoted 2 lines
Fixes 67306f84ca78c ("selftests/bpf: Add bpf_read_branch_records() selftest")Signed-off-by Matt Bobrowski <[email protected]>
Thanks for the fix!
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 4 lines · On Thu, 20 Nov 2025 14:20:59 +0000 you wrote:
Gracefully skip the
test_perf_branches_hwsubtest on platforms that do not support LBR or require specialized perf event attributes to enable branch sampling.
Quoted 8 lines
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.[...]
Here is the summary with links:
- [bpf-next] selftests/bpf: skip test_perf_branches_hw() on unsupported platforms
https://git.kernel.org/bpf/bpf-next/c/27746aaf1b20
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html