From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Joanne Koong <joannekoong@fb.com>, bpf@vger.kernel.org
Cc: Kernel-team@fb.com
Subject: Re: [PATCH bpf-next v4 1/5] bpf: Add bitset map with bloom filter capabilities
Date: Thu, 07 Oct 2021 16:20:12 +0200 [thread overview]
Message-ID: <87k0ioncgz.fsf@toke.dk> (raw)
In-Reply-To: <20211006222103.3631981-2-joannekoong@fb.com>
Joanne Koong <joannekoong@fb.com> writes:
> This patch adds the kernel-side changes for the implementation of
> a bitset map with bloom filter capabilities.
>
> The bitset map does not have keys, only values since it is a
> non-associative data type. When the bitset map is created, it must
> be created with a key_size of 0, and the max_entries value should be the
> desired size of the bitset, in number of bits.
>
> The bitset map supports peek (determining whether a bit is set in the
> map), push (setting a bit in the map), and pop (clearing a bit in the
> map) operations. These operations are exposed to userspace applications
> through the already existing syscalls in the following way:
>
> BPF_MAP_UPDATE_ELEM -> bpf_map_push_elem
> BPF_MAP_LOOKUP_ELEM -> bpf_map_peek_elem
> BPF_MAP_LOOKUP_AND_DELETE_ELEM -> bpf_map_pop_elem
>
> For updates, the user will pass in a NULL key and the index of the
> bit to set in the bitmap as the value. For lookups, the user will pass
> in the index of the bit to check as the value. If the bit is set, 0
> will be returned, else -ENOENT. For clearing the bit, the user will pass
> in the index of the bit to clear as the value.
This is interesting, and I can see other uses of such a data structure.
However, a couple of questions (talking mostly about the 'raw' bitmap
without the bloom filter enabled):
- How are you envisioning synchronisation to work? The code is using the
atomic set_bit() operation, but there's no test_and_{set,clear}_bit().
Any thoughts on how users would do this?
- It would be useful to expose the "find first set (ffs)" operation of
the bitmap as well. This can be added later, but thinking about the
API from the start would be good to avoid having to add a whole
separate helper for this. My immediate thought is to reserve peek(-1)
for this use - WDYT?
- Any thoughts on inlining the lookups? This should at least be feasible
for the non-bloom-filter type, but I'm not quite sure if the use of
map_extra allows the verifier to distinguish between the map types
(I'm a little fuzzy on how the inlining actually works)? And can
peek()/push()/pop() be inlined at all?
-Toke
next prev parent reply other threads:[~2021-10-07 14:20 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-06 22:20 [PATCH bpf-next v4 0/5] Implement bitset maps, with bloom filter Joanne Koong
2021-10-06 22:20 ` [PATCH bpf-next v4 1/5] bpf: Add bitset map with bloom filter capabilities Joanne Koong
2021-10-07 14:20 ` Toke Høiland-Jørgensen [this message]
2021-10-07 21:59 ` Joanne Koong
2021-10-08 21:57 ` Toke Høiland-Jørgensen
2021-10-08 23:11 ` Andrii Nakryiko
2021-10-09 13:10 ` Toke Høiland-Jørgensen
2021-10-12 3:17 ` Andrii Nakryiko
2021-10-12 12:48 ` Toke Høiland-Jørgensen
2021-10-12 22:46 ` Joanne Koong
2021-10-12 23:25 ` Zvi Effron
2021-10-13 1:17 ` Joanne Koong
2021-10-13 4:48 ` Alexei Starovoitov
2021-10-13 0:11 ` Martin KaFai Lau
2021-10-13 4:41 ` Alexei Starovoitov
2021-10-19 23:53 ` Andrii Nakryiko
2021-10-08 23:05 ` Andrii Nakryiko
2021-10-08 23:24 ` Zvi Effron
2021-10-09 0:16 ` Martin KaFai Lau
2021-10-06 22:21 ` [PATCH bpf-next v4 2/5] libbpf: Add "map_extra" as a per-map-type extra flag Joanne Koong
2021-10-08 23:19 ` Andrii Nakryiko
2021-10-20 21:08 ` Joanne Koong
2021-10-20 21:21 ` Andrii Nakryiko
2021-10-21 20:14 ` Joanne Koong
2021-10-21 21:41 ` Andrii Nakryiko
2021-10-09 2:12 ` Andrii Nakryiko
2021-10-06 22:21 ` [PATCH bpf-next v4 3/5] selftests/bpf: Add bitset map test cases Joanne Koong
2021-10-06 22:21 ` [PATCH bpf-next v4 4/5] bpf/benchs: Add benchmark tests for bloom filter throughput + false positive Joanne Koong
2021-10-06 22:35 ` Joanne Koong
2021-10-09 2:54 ` Andrii Nakryiko
2021-10-15 23:35 ` Joanne Koong
2021-10-20 0:46 ` Joanne Koong
2021-10-09 2:39 ` Andrii Nakryiko
2021-10-06 22:21 ` [PATCH bpf-next v4 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=87k0ioncgz.fsf@toke.dk \
--to=toke@redhat.com \
--cc=Kernel-team@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).