All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Cc: bpf <bpf@vger.kernel.org>, Andrii Nakryiko <andrii@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>
Subject: Re: [PATCH bpf-next v4 7/9] libbpf: add bpf_map__inner_map API
Date: Thu, 8 Apr 2021 23:57:22 -0700	[thread overview]
Message-ID: <CAEf4BzZLaFLkhu6GMOzP9spyKNAJbKaLwnHUYX6EsyCy6kGKOg@mail.gmail.com> (raw)
In-Reply-To: <20210408061310.95877-7-yauheni.kaliuta@redhat.com>

On Wed, Apr 7, 2021 at 11:14 PM Yauheni Kaliuta
<yauheni.kaliuta@redhat.com> wrote:
>
> From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
>
> The API gives access to inner map for map in map types (array or
> hash of map). It will be used to dynamically set max_entries in it.
>
> Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
> ---
>  tools/lib/bpf/libbpf.c   | 10 ++++++++++
>  tools/lib/bpf/libbpf.h   |  1 +
>  tools/lib/bpf/libbpf.map |  1 +
>  3 files changed, 12 insertions(+)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 7aad78dbb4b4..ed5586cce227 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -2194,6 +2194,7 @@ static int parse_btf_map_def(struct bpf_object *obj,
>                         map->inner_map = calloc(1, sizeof(*map->inner_map));
>                         if (!map->inner_map)
>                                 return -ENOMEM;
> +                       map->inner_map->fd = -1;
>                         map->inner_map->sec_idx = obj->efile.btf_maps_shndx;
>                         map->inner_map->name = malloc(strlen(map->name) +
>                                                       sizeof(".inner") + 1);
> @@ -3845,6 +3846,14 @@ __u32 bpf_map__max_entries(const struct bpf_map *map)
>         return map->def.max_entries;
>  }
>
> +struct bpf_map *bpf_map__inner_map(struct bpf_map *map)
> +{
> +       if (!bpf_map_type__is_map_in_map(map->def.type))
> +               return NULL;
> +
> +       return map->inner_map;
> +}
> +
>  int bpf_map__set_max_entries(struct bpf_map *map, __u32 max_entries)
>  {
>         if (map->fd >= 0)
> @@ -9476,6 +9485,7 @@ int bpf_map__set_inner_map_fd(struct bpf_map *map, int fd)
>                 pr_warn("error: inner_map_fd already specified\n");
>                 return -EINVAL;
>         }
> +       zfree(&map->inner_map);
>         map->inner_map_fd = fd;
>         return 0;
>  }
> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index f500621d28e5..bec4e6a6e31d 100644
> --- a/tools/lib/bpf/libbpf.h
> +++ b/tools/lib/bpf/libbpf.h
> @@ -480,6 +480,7 @@ LIBBPF_API int bpf_map__pin(struct bpf_map *map, const char *path);
>  LIBBPF_API int bpf_map__unpin(struct bpf_map *map, const char *path);
>
>  LIBBPF_API int bpf_map__set_inner_map_fd(struct bpf_map *map, int fd);
> +LIBBPF_API struct bpf_map *bpf_map__inner_map(struct bpf_map *map);
>
>  LIBBPF_API long libbpf_get_error(const void *ptr);
>
> diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
> index f5990f7208ce..9768daa75415 100644
> --- a/tools/lib/bpf/libbpf.map
> +++ b/tools/lib/bpf/libbpf.map
> @@ -349,6 +349,7 @@ LIBBPF_0.3.0 {
>                 ring_buffer__epoll_fd;
>                 xsk_setup_xdp_prog;
>                 xsk_socket__update_xskmap;
> +               bpf_map__inner_map;

This is neither in the right version (should be in 0.4.0) nor is in
alphabetical order (despite cover letter saying otherwise).
But I've fixed it up while applying. Please be more careful next time.

>  } LIBBPF_0.2.0;
>
>  LIBBPF_0.4.0 {

> --
> 2.31.1
>

  reply	other threads:[~2021-04-09  6:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08  6:12 [PATCH bpf-next v4 0/9] bpf/selftests: page size fixes Yauheni Kaliuta
2021-04-08  6:13 ` [PATCH bpf-next v4 1/9] selftests/bpf: test_progs/sockopt_sk: remove version Yauheni Kaliuta
2021-04-08  6:13   ` [PATCH bpf-next v4 2/9] selftests/bpf: test_progs/sockopt_sk: Convert to use BPF skeleton Yauheni Kaliuta
2021-04-08  6:13   ` [PATCH bpf-next v4 3/9] selftests/bpf: pass page size from userspace in sockopt_sk Yauheni Kaliuta
2021-04-08  6:13   ` [PATCH bpf-next v4 4/9] selftests/bpf: pass page size from userspace in map_ptr Yauheni Kaliuta
2021-04-08  6:13   ` [PATCH bpf-next v4 5/9] selftests/bpf: mmap: use runtime page size Yauheni Kaliuta
2021-04-08  6:13   ` [PATCH bpf-next v4 6/9] selftests/bpf: ringbuf: " Yauheni Kaliuta
2021-04-08  6:13   ` [PATCH bpf-next v4 7/9] libbpf: add bpf_map__inner_map API Yauheni Kaliuta
2021-04-09  6:57     ` Andrii Nakryiko [this message]
2021-04-08  6:13   ` [PATCH bpf-next v4 8/9] selftests/bpf: ringbuf_multi: use runtime page size Yauheni Kaliuta
2021-04-08  6:13   ` [PATCH bpf-next v4 9/9] selftests/bpf: ringbuf_multi: test bpf_map__set_inner_map_fd Yauheni Kaliuta
2021-04-09  6:56     ` 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=CAEf4BzZLaFLkhu6GMOzP9spyKNAJbKaLwnHUYX6EsyCy6kGKOg@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jolsa@redhat.com \
    --cc=yauheni.kaliuta@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 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.