From: Mykyta Yatsenko Problem: bpf_cookie selftest fails if it runs after task_work selftest: perf_event_open fails with errno=EINVAL. EINVAL indicates incorrect/invalid input argument, which in case of bpf_cookie can only point to sample_freq attribute. Possible root cause: When running task_work test, we can see that perf subsystem lowers kernel.perf_event_max_sample_rate which probably is the side-effect of the test that make bpf_cookie fail. Solution: Set perf_event_open sampling rate attribute for bpf_cookie the same as task_work - this is the most reliable solution for this, changing task_work sampling rate resulted in task_work test becoming flaky. Signed-off-by: Mykyta Yatsenko --- tools/testing/selftests/bpf/prog_tests/bpf_cookie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c index 4a0670c056ba..53a3bf435479 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c @@ -450,8 +450,8 @@ static void pe_subtest(struct test_bpf_cookie *skel) attr.size = sizeof(attr); attr.type = PERF_TYPE_SOFTWARE; attr.config = PERF_COUNT_SW_CPU_CLOCK; - attr.freq = 1; - attr.sample_freq = 10000; + attr.sample_period = 100000; + pfd = syscall(__NR_perf_event_open, &attr, -1, 0, -1, PERF_FLAG_FD_CLOEXEC); if (!ASSERT_GE(pfd, 0, "perf_fd")) goto cleanup; -- 2.51.0