Re: [PATCH v2 bpf-next 5/7] selftests/bpf: add BPF ringbuf selftests
From: Andrii Nakryiko <hidden>
Date: 2020-05-22 18:58:36
Also in:
bpf
On Thu, May 21, 2020 at 6:20 PM Alexei Starovoitov [off-list ref] wrote:
On Sun, May 17, 2020 at 12:57:25PM -0700, Andrii Nakryiko wrote:quoted
diff --git a/tools/testing/selftests/bpf/progs/test_ringbuf_multi.c b/tools/testing/selftests/bpf/progs/test_ringbuf_multi.c new file mode 100644 index 000000000000..7eb85dd9cd66 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/test_ringbuf_multi.c@@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2019 Facebookoops ;)
heh, still living in good old 2019... :) fixing...
quoted
+ +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +char _license[] SEC("license") = "GPL"; + +struct sample { + int pid; + int seq; + long value; + char comm[16]; +}; + +struct ringbuf_map { + __uint(type, BPF_MAP_TYPE_RINGBUF); + __uint(max_entries, 1 << 12); +} ringbuf1 SEC(".maps"), + ringbuf2 SEC(".maps"); + +struct { + __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS); + __uint(max_entries, 4); + __type(key, int); + __array(values, struct ringbuf_map); +} ringbuf_arr SEC(".maps") = { + .values = { + [0] = &ringbuf1, + [2] = &ringbuf2, + }, +};the tests look great. Very easy to understand the usage model.
great, thanks!