All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Takshak Chahande <ctakshak@fb.com>
Cc: Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	ndixit@fb.com, Martin Lau <kafai@fb.com>,
	Andrii Nakryiko <andriin@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH v3 bpf-next 2/2] selftests/bpf: handle batch operations for map-in-map bpf-maps
Date: Wed, 27 Apr 2022 13:14:28 -0700	[thread overview]
Message-ID: <CAEf4BzYp=cjjq2q0LN-ePYADtL0-J_EnbnAJoPGwKYKXX2JjWw@mail.gmail.com> (raw)
In-Reply-To: <20220425184149.1173545-2-ctakshak@fb.com>

On Mon, Apr 25, 2022 at 11:42 AM Takshak Chahande <ctakshak@fb.com> wrote:
>
> This patch adds up test cases that handles 4 combinations:
> a) outer map: BPF_MAP_TYPE_ARRAY_OF_MAPS
>    inner maps: BPF_MAP_TYPE_ARRAY and BPF_MAP_TYPE_HASH
> b) outer map: BPF_MAP_TYPE_HASH_OF_MAPS
>    inner maps: BPF_MAP_TYPE_ARRAY and BPF_MAP_TYPE_HASH
>
> v2->v3:
> - Handled transient ENOSPC correctly, bug was found in BPF CI (Daniel)
>
> v1->v2:
> - Fixed no format arguments error (Andrii)
>
> Signed-off-by: Takshak Chahande <ctakshak@fb.com>
> ---

Is there any extra benefit in putting these test under test_maps
instead of test_progs? test_progs has better "testing infra", it's
easier to isolate and debug tests, skip them or run just the ones you
want, better logging, better ASSERT_xxx() macros for testing, etc.

I see that you create a fixed amount of inner maps, etc. It's all
actually simpler to do in test_progs using BPF-side code. See other
examples under progs/ that show how to create and initialize
map-in-maps.


>  .../bpf/map_tests/map_in_map_batch_ops.c      | 239 ++++++++++++++++++
>  1 file changed, 239 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/map_tests/map_in_map_batch_ops.c
>

[...]

> +static int create_outer_map(enum bpf_map_type map_type, __u32 inner_map_fd)
> +{
> +       int outer_map_fd;
> +
> +       LIBBPF_OPTS(bpf_map_create_opts, attr);

LIBBPF_OPTS() is declaring a variable, it should go together with
other variables

> +       attr.inner_map_fd = inner_map_fd;
> +       outer_map_fd = bpf_map_create(map_type, "outer_map", sizeof(__u32),
> +                                     sizeof(__u32), OUTER_MAP_ENTRIES,
> +                                     &attr);
> +       CHECK(outer_map_fd < 0,
> +             "outer bpf_map_create()",
> +             "map_type=(%d), error:%s\n",
> +             map_type, strerror(errno));
> +
> +       return outer_map_fd;
> +}
> +

[...]

> +static void _map_in_map_batch_ops(enum bpf_map_type outer_map_type,
> +                                 enum bpf_map_type inner_map_type)
> +{
> +       __u32 *outer_map_keys, *inner_map_fds;
> +       __u32 max_entries = OUTER_MAP_ENTRIES;
> +       __u32 value_size = sizeof(__u32);
> +       int batch_size[2] = {5, 10};
> +       __u32 map_index, op_index;
> +       int outer_map_fd, ret;
> +       DECLARE_LIBBPF_OPTS(bpf_map_batch_opts, opts,

nit: prefere shorter LIBBPF_OPTS(). as for zero initialization of
elem_flags and flags, they are zero-initialized by default by
LIBBPF_OPTS, so you can just drop two lines below

> +                           .elem_flags = 0,
> +                           .flags = 0,
> +       );
> +
> +       outer_map_keys = calloc(max_entries, value_size);
> +       inner_map_fds = calloc(max_entries, value_size);
> +       create_inner_maps(inner_map_type, inner_map_fds);
> +

[...]

  reply	other threads:[~2022-04-27 20:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25 18:41 [PATCH v3 bpf-next 1/2] bpf: Extend batch operations for map-in-map bpf-maps Takshak Chahande
2022-04-25 18:41 ` [PATCH v3 bpf-next 2/2] selftests/bpf: handle " Takshak Chahande
2022-04-27 20:14   ` Andrii Nakryiko [this message]
2022-04-28 20:59   ` Yonghong Song
2022-04-27 20:15 ` [PATCH v3 bpf-next 1/2] bpf: Extend " Andrii Nakryiko
2022-04-28 20:21 ` Yonghong Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEf4BzYp=cjjq2q0LN-ePYADtL0-J_EnbnAJoPGwKYKXX2JjWw@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=ctakshak@fb.com \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=ndixit@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.