Re: [PATCH v2 bpf-next 5/7] selftests/bpf: add BPF ringbuf selftests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 17, 2020 at 12:57:25PM -0700, Andrii Nakryiko wrote:
> 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 Facebook

oops ;)

> +
> +#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.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux