Skip to content

Commit

Permalink
selftests/bpf: Test libbpf's ringbuf size fix up logic
Browse files Browse the repository at this point in the history
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
  • Loading branch information
anakryiko authored and borkmann committed May 9, 2022
1 parent 0087a68 commit 7b3a063
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 0 additions & 12 deletions tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/bpf/progs/test_ringbuf_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 7b3a063

Please sign in to comment.