selftests/bpf: Test libbpf's ringbuf size fix up logic
authorAndrii Nakryiko <andrii@kernel.org>
Mon, 9 May 2022 00:41:48 +0000 (17:41 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 9 May 2022 15:15:32 +0000 (17:15 +0200)
Make sure we always excercise libbpf's ringbuf map size adjustment logic
by specifying non-zero size that's definitely not a page size multiple.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220509004148.1801791-10-andrii@kernel.org
tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c
tools/testing/selftests/bpf/progs/test_ringbuf_multi.c

index e945195b24c98c654dbd8a9173725953a364de24..eb5f7f5aa81a27b404a8adf3d76a7e4cdbf8a61a 100644 (file)
@@ -50,18 +50,6 @@ void test_ringbuf_multi(void)
        if (CHECK(!skel, "skel_open", "skeleton open failed\n"))
                return;
 
-       err = bpf_map__set_max_entries(skel->maps.ringbuf1, page_size);
-       if (CHECK(err != 0, "bpf_map__set_max_entries", "bpf_map__set_max_entries failed\n"))
-               goto cleanup;
-
-       err = bpf_map__set_max_entries(skel->maps.ringbuf2, page_size);
-       if (CHECK(err != 0, "bpf_map__set_max_entries", "bpf_map__set_max_entries failed\n"))
-               goto cleanup;
-
-       err = bpf_map__set_max_entries(bpf_map__inner_map(skel->maps.ringbuf_arr), page_size);
-       if (CHECK(err != 0, "bpf_map__set_max_entries", "bpf_map__set_max_entries failed\n"))
-               goto cleanup;
-
        proto_fd = bpf_map_create(BPF_MAP_TYPE_RINGBUF, NULL, 0, 0, page_size, NULL);
        if (CHECK(proto_fd < 0, "bpf_map_create", "bpf_map_create failed\n"))
                goto cleanup;
index 197b86546dca24c2558268d6c661ecd4dfc45bdb..e416e0ce12b7ddb37478137eb4e1c9147d90a1e1 100644 (file)
@@ -15,6 +15,8 @@ struct sample {
 
 struct ringbuf_map {
        __uint(type, BPF_MAP_TYPE_RINGBUF);
+       /* libbpf will adjust to valid page size */
+       __uint(max_entries, 1000);
 } ringbuf1 SEC(".maps"),
   ringbuf2 SEC(".maps");