From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Joanne Koong <joannekoong@fb.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
Kernel Team <Kernel-team@fb.com>,
Andrii Nakryiko <andrii@kernel.org>
Subject: Re: [PATCH v5 bpf-next 2/5] libbpf: Add "map_extra" as a per-map-type extra flag
Date: Wed, 27 Oct 2021 11:41:13 -0700 [thread overview]
Message-ID: <CAEf4Bza1rz+R_nioirOqv1KxUPWuR7uBc5zQ+_EdWqnTJfbdDA@mail.gmail.com> (raw)
In-Reply-To: <1d6fff4c-eaaf-09d3-7d9f-4d5184048fd6@fb.com>
On Wed, Oct 27, 2021 at 11:39 AM Joanne Koong <joannekoong@fb.com> wrote:
>
> On 10/26/21 8:30 PM, Andrii Nakryiko wrote:
>
> >
> > On 10/22/21 3:02 PM, Joanne Koong wrote:
> >> This patch adds the libbpf infrastructure for supporting a
> >> per-map-type "map_extra" field, whose definition will be
> >> idiosyncratic depending on map type.
> >>
> >> For example, for the bloom filter map, the lower 4 bits of
> >> map_extra is used to denote the number of hash functions.
> >>
> >> Please note that until libbpf 1.0 is here, the
> >> "bpf_create_map_params" struct is used as a temporary
> >> means for propagating the map_extra field to the kernel.
> >>
> >> Signed-off-by: Joanne Koong <joannekoong@fb.com>
> >> ---
> >> include/uapi/linux/bpf.h | 1 +
> >> tools/include/uapi/linux/bpf.h | 1 +
> >> tools/lib/bpf/bpf.c | 27 ++++++++++++++++++++-
> >> tools/lib/bpf/bpf_gen_internal.h | 2 +-
> >> tools/lib/bpf/gen_loader.c | 3 ++-
> >> tools/lib/bpf/libbpf.c | 41 ++++++++++++++++++++++++++++----
> >> tools/lib/bpf/libbpf.h | 3 +++
> >> tools/lib/bpf/libbpf.map | 2 ++
> >> tools/lib/bpf/libbpf_internal.h | 25 ++++++++++++++++++-
> >> 9 files changed, 96 insertions(+), 9 deletions(-)
> [...]
> >> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> >> index db6e48014839..751cfb9778dc 100644
> >> --- a/tools/lib/bpf/libbpf.c
> >> +++ b/tools/lib/bpf/libbpf.c
> >> @@ -400,6 +400,7 @@ struct bpf_map {
> >> char *pin_path;
> >> bool pinned;
> >> bool reused;
> >> + __u64 map_extra;
> >> };
> >> enum extern_type {
> >> @@ -2313,6 +2314,17 @@ int parse_btf_map_def(const char *map_name,
> >> struct btf *btf,
> >> }
> >> map_def->pinning = val;
> >> map_def->parts |= MAP_DEF_PINNING;
> >> + } else if (strcmp(name, "map_extra") == 0) {
> >> + /*
> >> + * TODO: When the BTF array supports __u64s, read into
> >> + * map_def->map_extra directly.
> >> + */
> >
> > Please drop the TODO comment. There are no plans to extend BTF arrays
> > to support __u64 sizes.
> >
> I see, I will remove this.
>
> If BTF arrays never support __u64 sizes, then people won't be able to
> define a map in libbpf
> that uses bits 33 - 64 of the map_extra field, correct? Or is there a
> workaround for them that
> I'm not seeing?
Right, they won't be able to do it declaratively (if we ever need
higher 32 bits). They will still be able to specify map_extra
programmatically through bpf_map__set_map_extra() and with low-level
map creation APIs. So not ideal, but there will be a work-around.
>
> >
> > [...]
> >
next prev parent reply other threads:[~2021-10-27 18:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 22:02 [PATCH v5 bpf-next 0/5] Implement bloom filter map Joanne Koong
2021-10-22 22:02 ` [PATCH v5 bpf-next 1/5] bpf: Add bloom filter map implementation Joanne Koong
2021-10-26 0:43 ` Martin KaFai Lau
2021-10-26 19:47 ` Joanne Koong
2021-10-27 3:18 ` Andrii Nakryiko
2021-10-27 19:13 ` Joanne Koong
2021-10-27 19:16 ` Andrii Nakryiko
2021-10-22 22:02 ` [PATCH v5 bpf-next 2/5] libbpf: Add "map_extra" as a per-map-type extra flag Joanne Koong
2021-10-26 1:31 ` Martin KaFai Lau
2021-10-27 3:30 ` Andrii Nakryiko
2021-10-27 18:39 ` Joanne Koong
2021-10-27 18:41 ` Andrii Nakryiko [this message]
2021-10-22 22:02 ` [PATCH v5 bpf-next 3/5] selftests/bpf: Add bloom filter map test cases Joanne Koong
2021-10-27 3:35 ` Andrii Nakryiko
2021-10-22 22:02 ` [PATCH v5 bpf-next 4/5] bpf/benchs: Add benchmark tests for bloom filter throughput + false positive Joanne Koong
2021-10-27 3:49 ` Andrii Nakryiko
2021-10-22 22:02 ` [PATCH v5 bpf-next 5/5] bpf/benchs: Add benchmarks for comparing hashmap lookups w/ vs. w/out bloom filter Joanne Koong
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=CAEf4Bza1rz+R_nioirOqv1KxUPWuR7uBc5zQ+_EdWqnTJfbdDA@mail.gmail.com \
--to=andrii.nakryiko@gmail.com \
--cc=Kernel-team@fb.com \
--cc=andrii@kernel.org \
--cc=andriin@fb.com \
--cc=bpf@vger.kernel.org \
--cc=joannekoong@fb.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).