]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: bpf_cookie: Make perf_event subtest trigger reliably
authorSun Jian <sun.jian.kdev@gmail.com>
Sat, 28 Feb 2026 07:45:55 +0000 (15:45 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 5 Mar 2026 23:07:40 +0000 (15:07 -0800)
commit7f20d371fd879f5bb9be739c86c9bac13ea920c8
tree3c3e12a0901a7d339cb62e9b530b85566923f63f
parent74d3305e620b3c71b414198f9cf9b1609148d277
selftests/bpf: bpf_cookie: Make perf_event subtest trigger reliably

The perf_event subtest relies on SW_CPU_CLOCK sampling to trigger the BPF
program, but the current CPU burn loop can be too short on slower systems
and may fail to generate any overflow sample. This leaves pe_res unchanged
and makes the test flaky.

Make burn_cpu() take a loop count and use a longer burn only for the
perf_event subtest. Also scope perf_event_open() to the current task to
avoid wasting samples on unrelated activity.

Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20260228074555.122950-3-sun.jian.kdev@gmail.com
tools/testing/selftests/bpf/prog_tests/bpf_cookie.c