提交 8300a990 编写于 作者: Y Yauheni Kaliuta 提交者: Zheng Zengkai

selftests/bpf: ringbuf_multi: Use runtime page size

mainline inclusion
from mainline-5.13-rc1
commit f3f4c23e
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f3f4c23e1238783f3d719cfbda6c5e2fd03a48c4

-------------------------------------------------

Set bpf table sizes dynamically according to the runtime page size
value.

Do not switch to ASSERT macros, keep CHECK, for consistency with the
rest of the test. Can be a separate cleanup patch.
Signed-off-by: NYauheni Kaliuta <yauheni.kaliuta@redhat.com>
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210408061310.95877-8-yauheni.kaliuta@redhat.com
(cherry picked from commit f3f4c23e)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 fd430507
...@@ -41,13 +41,30 @@ static int process_sample(void *ctx, void *data, size_t len) ...@@ -41,13 +41,30 @@ static int process_sample(void *ctx, void *data, size_t len)
void test_ringbuf_multi(void) void test_ringbuf_multi(void)
{ {
struct test_ringbuf_multi *skel; struct test_ringbuf_multi *skel;
struct ring_buffer *ringbuf; struct ring_buffer *ringbuf = NULL;
int err; int err;
int page_size = getpagesize();
skel = test_ringbuf_multi__open_and_load(); skel = test_ringbuf_multi__open();
if (CHECK(!skel, "skel_open_load", "skeleton open&load failed\n")) if (CHECK(!skel, "skel_open", "skeleton open failed\n"))
return; 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;
err = test_ringbuf_multi__load(skel);
if (CHECK(err != 0, "skel_load", "skeleton load failed\n"))
goto cleanup;
/* only trigger BPF program for current process */ /* only trigger BPF program for current process */
skel->bss->pid = getpid(); skel->bss->pid = getpid();
......
...@@ -15,7 +15,6 @@ struct sample { ...@@ -15,7 +15,6 @@ struct sample {
struct ringbuf_map { struct ringbuf_map {
__uint(type, BPF_MAP_TYPE_RINGBUF); __uint(type, BPF_MAP_TYPE_RINGBUF);
__uint(max_entries, 1 << 12);
} ringbuf1 SEC(".maps"), } ringbuf1 SEC(".maps"),
ringbuf2 SEC(".maps"); ringbuf2 SEC(".maps");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册