selftests/bpf: Wait for the last maps of map_kptr to be freed

map_kptr_race/htab_leak fails occasionally in a complete run of test_progs:

  test_htab_leak:FAIL:htab refcount unexpected htab refcount:
  actual 6 != expected 2

This is a race between two tests. It is not a leak in the kernel.
 - map_kptr runs immediately before htab_leak. The two tests examine the
   refcount of the same test object.
 - The kernel frees maps asynchronously. Thus the maps drop their
   references some time after close().
 - map_kptr waits for that after each subtest, but not after the last one.

Wait after the last subtest too.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261027190314.1440199-10-alexei.starovoitov@gmail.com
This commit is contained in:
Alexei Starovoitov 2026-10-27 19:03:04 +00:00
parent 1651157604
commit 2ad395a384
No known key found for this signature in database

View File

@ -225,6 +225,11 @@ void serial_test_map_kptr(void)
/* Observe refcount dropping to 1 on map release. */
test_map_kptr_success(true);
/* The next test counts the same references */
ASSERT_OK(kern_sync_rcu_tasks_trace(skel), "sync rcu_tasks_trace");
ASSERT_OK(kern_sync_rcu(), "sync rcu");
wait_for_map_release();
}
rcu_tasks_trace_gp__destroy(skel);