After destroying the skeleton and dropping the last mmap of the .data
map, test_mmap polls for the map ID to go away, up to 10000 times with
usleep(1) in between, and then checks that the ID can't be used anymore.
The map goes away only when the program that uses it is freed, which
happens in a work item after an RCU grace period. With other tests
running in parallel, that can take longer than the polling, and the
test still gets an FD for the map ID.
Poll until the map ID is gone. The watchdog of test_progs kills the
test if the map is never freed.
Fixes: 642c16547027 ("selftests/bpf: Validate frozen map contents stays frozen")
Signed-off-by: Qiliang Yuan <[email protected]>
---
tools/testing/selftests/bpf/prog_tests/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/mmap.c
b/tools/testing/selftests/bpf/prog_tests/mmap.c
index a271d5a0f7aba..0e297ed5da0fd 100644
--- a/tools/testing/selftests/bpf/prog_tests/mmap.c
+++ b/tools/testing/selftests/bpf/prog_tests/mmap.c
@@ -280,7 +280,7 @@ void test_mmap(void)
munmap(tmp1, map_sz);
/* we need to wait for RCU grace period */
- for (i = 0; i < 10000; i++) {
+ while (true) {
__u32 id = data_map_id - 1;
if (bpf_map_get_next_id(id, &id) || id > data_map_id)
break;
---
base-commit: e1d84a37cba984388988d2f1ddc84561413f0db2
change-id: 20261009-selftests-bpf-mmap-wait-map-free-6bffaf4dfcf2
Best regards,
--
Qiliang Yuan <[email protected]>