netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Andrii Nakryiko <andriin@fb.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, ast@fb.com,
	daniel@iogearbox.net, toke@redhat.com, andrii.nakryiko@gmail.com,
	kernel-team@fb.com
Subject: Re: [PATCH v2 bpf-next 3/3] libbpf: add BTF-defined map-in-map support
Date: Tue, 28 Apr 2020 11:03:36 -0700	[thread overview]
Message-ID: <20200428180336.b26olfmjb7ntipvb@ast-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20200428064140.122796-4-andriin@fb.com>

On Mon, Apr 27, 2020 at 11:41:39PM -0700, Andrii Nakryiko wrote:
> diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h
> index 60aad054eea1..e3a6e9a1f5b4 100644
> --- a/tools/lib/bpf/bpf_helpers.h
> +++ b/tools/lib/bpf/bpf_helpers.h
> @@ -12,6 +12,7 @@
>  
>  #define __uint(name, val) int (*name)[val]
>  #define __type(name, val) typeof(val) *name
> +#define __inner(name, val) typeof(val) *name[]
...
> +++ b/tools/testing/selftests/bpf/progs/test_btf_map_in_map.c
> @@ -0,0 +1,76 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Copyright (c) 2020 Facebook */
> +#include <linux/bpf.h>
> +#include <bpf/bpf_helpers.h>
> +
> +struct inner_map {
> +	__uint(type, BPF_MAP_TYPE_ARRAY);
> +	__uint(max_entries, 1);
> +	__type(key, int);
> +	__type(value, int);
> +} inner_map1 SEC(".maps"),
> +  inner_map2 SEC(".maps");
> +
> +struct outer_arr {
> +	__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
> +	__uint(max_entries, 3);
> +	__uint(key_size, sizeof(int));
> +	__uint(value_size, sizeof(int));
> +	/* it's possible to use anonymous struct as inner map definition here */
> +	__inner(values, struct {
> +		__uint(type, BPF_MAP_TYPE_ARRAY);
> +		/* changing max_entries to 2 will fail during load
> +		 * due to incompatibility with inner_map definition */
> +		__uint(max_entries, 1);
> +		__type(key, int);
> +		__type(value, int);
> +	});

How about renaming it s/__inner/__array/ ?
Because that's what it defines from BTF pov.

  parent reply	other threads:[~2020-04-28 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  6:41 [PATCH v2 bpf-next 0/3] Add BTF-defined map-in-map support to libbpf Andrii Nakryiko
2020-04-28  6:41 ` [PATCH v2 bpf-next 1/3] libbpf: refactor BTF-defined map definition parsing logic Andrii Nakryiko
2020-04-28  6:41 ` [PATCH v2 bpf-next 2/3] libbpf: refactor map creation logic and fix cleanup leak Andrii Nakryiko
2020-04-28 10:48   ` Toke Høiland-Jørgensen
2020-04-28  6:41 ` [PATCH v2 bpf-next 3/3] libbpf: add BTF-defined map-in-map support Andrii Nakryiko
2020-04-28 11:03   ` Toke Høiland-Jørgensen
2020-04-28 18:03   ` Alexei Starovoitov [this message]
2020-04-28 18:35     ` Andrii Nakryiko

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=20200428180336.b26olfmjb7ntipvb@ast-mbp.dhcp.thefacebook.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).