Skip to content

Commit 58eab45

Browse files
Hou TaoKernel Patches Daemon
Hou Tao
authored and
Kernel Patches Daemon
committed
selftests/bpf: Remove the liveness test for inner map
Even before the introduction of deferred-map-put for inner map, the liveness test for inner map is not correct, because inner_map1 and inner_map2 are released directly in a kworker and there is no need for invoking kern_sync_rcu(). After deferring the invocation of bpf_map_put() for inner map, the time when the inner map is released is more complicated: each overwrite of the inner map will delay the release of the inner map after both one RCU grace period and one tasks trace RCU grace period. To avoid such complexity in selftest, just remove the liveness test for inner map. Signed-off-by: Hou Tao <[email protected]>
1 parent 29d2214 commit 58eab45

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static void test_lookup_update(void)
2525
int map1_fd, map2_fd, map3_fd, map4_fd, map5_fd, map1_id, map2_id;
2626
int outer_arr_fd, outer_hash_fd, outer_arr_dyn_fd;
2727
struct test_btf_map_in_map *skel;
28-
int err, key = 0, val, i, fd;
28+
int err, key = 0, val, i;
2929

3030
skel = test_btf_map_in_map__open_and_load();
3131
if (CHECK(!skel, "skel_open", "failed to open&load skeleton\n"))
@@ -102,30 +102,6 @@ static void test_lookup_update(void)
102102
CHECK(map1_id == 0, "map1_id", "failed to get ID 1\n");
103103
CHECK(map2_id == 0, "map2_id", "failed to get ID 2\n");
104104

105-
test_btf_map_in_map__destroy(skel);
106-
skel = NULL;
107-
108-
/* we need to either wait for or force synchronize_rcu(), before
109-
* checking for "still exists" condition, otherwise map could still be
110-
* resolvable by ID, causing false positives.
111-
*
112-
* Older kernels (5.8 and earlier) freed map only after two
113-
* synchronize_rcu()s, so trigger two, to be entirely sure.
114-
*/
115-
CHECK(kern_sync_rcu(), "sync_rcu", "failed\n");
116-
CHECK(kern_sync_rcu(), "sync_rcu", "failed\n");
117-
118-
fd = bpf_map_get_fd_by_id(map1_id);
119-
if (CHECK(fd >= 0, "map1_leak", "inner_map1 leaked!\n")) {
120-
close(fd);
121-
goto cleanup;
122-
}
123-
fd = bpf_map_get_fd_by_id(map2_id);
124-
if (CHECK(fd >= 0, "map2_leak", "inner_map2 leaked!\n")) {
125-
close(fd);
126-
goto cleanup;
127-
}
128-
129105
cleanup:
130106
test_btf_map_in_map__destroy(skel);
131107
}

0 commit comments

Comments
 (0)