|
| 1 | +From f3d2080e8cf23125f79e345061149ae40f66816f Mon Sep 17 00:00:00 2001 |
| 2 | +From: Song Liu < [email protected]> |
| 3 | +Date: Mon, 3 Jun 2024 23:43:17 -0700 |
| 4 | +Subject: [PATCH bpf-next] selftests/bpf: Fix bpf_cookie and find_vma in nested |
| 5 | + VM |
| 6 | + |
| 7 | +bpf_cookie and find_vma are flaky in nested VMs, which is used by some CI |
| 8 | +systems. It turns out these failures are caused by unreliable perf event |
| 9 | +in nested VM. Fix these by: |
| 10 | + |
| 11 | + 1. Use PERF_COUNT_SW_CPU_CLOCK in find_vma; |
| 12 | + 2. Increase sample_freq in bpf_cookie. |
| 13 | + |
| 14 | +Signed-off-by: Song Liu < [email protected]> |
| 15 | +--- |
| 16 | + tools/testing/selftests/bpf/prog_tests/bpf_cookie.c | 2 +- |
| 17 | + tools/testing/selftests/bpf/prog_tests/find_vma.c | 4 ++-- |
| 18 | + 2 files changed, 3 insertions(+), 3 deletions(-) |
| 19 | + |
| 20 | +diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c |
| 21 | +index 4407ea428e77..070c52c312e5 100644 |
| 22 | +--- a/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c |
| 23 | ++++ b/tools/testing/selftests/bpf/prog_tests/bpf_cookie.c |
| 24 | +@@ -451,7 +451,7 @@ static void pe_subtest(struct test_bpf_cookie *skel) |
| 25 | + attr.type = PERF_TYPE_SOFTWARE; |
| 26 | + attr.config = PERF_COUNT_SW_CPU_CLOCK; |
| 27 | + attr.freq = 1; |
| 28 | +- attr.sample_freq = 1000; |
| 29 | ++ attr.sample_freq = 10000; |
| 30 | + pfd = syscall(__NR_perf_event_open, &attr, -1, 0, -1, PERF_FLAG_FD_CLOEXEC); |
| 31 | + if (!ASSERT_GE(pfd, 0, "perf_fd")) |
| 32 | + goto cleanup; |
| 33 | +diff --git a/tools/testing/selftests/bpf/prog_tests/find_vma.c b/tools/testing/selftests/bpf/prog_tests/find_vma.c |
| 34 | +index 5165b38f0e59..f7619e0ade10 100644 |
| 35 | +--- a/tools/testing/selftests/bpf/prog_tests/find_vma.c |
| 36 | ++++ b/tools/testing/selftests/bpf/prog_tests/find_vma.c |
| 37 | +@@ -29,8 +29,8 @@ static int open_pe(void) |
| 38 | + |
| 39 | + /* create perf event */ |
| 40 | + attr.size = sizeof(attr); |
| 41 | +- attr.type = PERF_TYPE_HARDWARE; |
| 42 | +- attr.config = PERF_COUNT_HW_CPU_CYCLES; |
| 43 | ++ attr.type = PERF_TYPE_SOFTWARE; |
| 44 | ++ attr.config = PERF_COUNT_SW_CPU_CLOCK; |
| 45 | + attr.freq = 1; |
| 46 | + attr.sample_freq = 1000; |
| 47 | + pfd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, PERF_FLAG_FD_CLOEXEC); |
| 48 | +-- |
| 49 | +2.43.0 |
| 50 | + |
0 commit comments