Skip to content

Commit 34a5669

Browse files
committed
selftests/bpf: fix flaky bpf_cookie selftest
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 <[email protected]>
1 parent 348f611 commit 34a5669

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ static void pe_subtest(struct test_bpf_cookie *skel)
450450
attr.size = sizeof(attr);
451451
attr.type = PERF_TYPE_SOFTWARE;
452452
attr.config = PERF_COUNT_SW_CPU_CLOCK;
453-
attr.freq = 1;
454-
attr.sample_freq = 10000;
453+
attr.sample_period = 100000;
454+
455455
pfd = syscall(__NR_perf_event_open, &attr, -1, 0, -1, PERF_FLAG_FD_CLOEXEC);
456456
if (!ASSERT_GE(pfd, 0, "perf_fd"))
457457
goto cleanup;

0 commit comments

Comments
 (0)