Skip to content

Commit 881b8eb

Browse files
Yonghong SongKernel Patches Daemon
authored andcommitted
selftests/bpf: Fix flaky test_btf_id test
With previous patch, one of subtests in test_btf_id becomes flaky and may fail. The following is a failing example: Error: #26 btf Error: #26/174 btf/BTF ID Error: #26/174 btf/BTF ID btf_raw_create:PASS:check 0 nsec btf_raw_create:PASS:check 0 nsec test_btf_id:PASS:check 0 nsec ... test_btf_id:PASS:check 0 nsec test_btf_id:FAIL:check BTF lingersdo_test_get_info:FAIL:check failed: -1 The test tries to prove a btf_id not available after the map is closed. But btf_id is freed only after workqueue and a rcu grace period, compared to previous case just after a rcu grade period. To fix the flaky test, I added a kern_sync_rcu() after closing map and before querying btf id availability, essentially ensuring a rcu grace period in the kernel, which seems making the test happy. Signed-off-by: Yonghong Song <[email protected]>
1 parent ca3a76a commit 881b8eb

File tree

1 file changed

+1
-0
lines changed
  • tools/testing/selftests/bpf/prog_tests

1 file changed

+1
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,6 +4629,7 @@ static int test_btf_id(unsigned int test_num)
46294629

46304630
/* The map holds the last ref to BTF and its btf_id */
46314631
close(map_fd);
4632+
kern_sync_rcu();
46324633
map_fd = -1;
46334634
btf_fd[0] = bpf_btf_get_fd_by_id(map_info.btf_id);
46344635
if (CHECK(btf_fd[0] >= 0, "BTF lingers")) {

0 commit comments

Comments
 (0)