Re: [PATCH bpf-next] bpf: add lookup_and_delete_elem support to hashtab
From: Andrii Nakryiko <hidden>
Date: 2021-02-23 00:54:27
On Tue, Feb 16, 2021 at 10:00 AM Denis Salopek [off-list ref] wrote:
On Mon, Feb 08, 2021 at 09:44:59PM -0800, Andrii Nakryiko wrote:quoted
On Wed, Jan 27, 2021 at 9:15 AM Denis Salopek [off-list ref] wrote:quoted
Extend the existing bpf_map_lookup_and_delete_elem() functionality to hashtab maps, in addition to stacks and queues. Create a new hashtab bpf_map_ops function that does lookup and deletion of the element under the same bucket lock and add the created map_ops to bpf.h. Add the appropriate test case to 'maps' selftests. Signed-off-by: Denis Salopek <redacted> Cc: Juraj Vijtiuk <redacted> Cc: Luka Oreskovic <redacted> Cc: Luka Perkov <luka.perkov@sartura.hr> ---I think this patch somehow got lost, even though it seems like a good addition. I'd recommend rebasing and re-submitting to let people take a fresh look at this. It would also be nice to have a test_progs test added, not just test_maps. I'd also look at supporting lookup_and_delete for other kinds of hash maps (LRU, per-CPU), so that the support is more complete. Thanks!Hi Andrii, I'll also implement the LRU and per-CPU ones and resubmit. I don't quite understand the test_progs, what kind of test(s) exactly should I add there?
test_progs is our preferred test runner. It's a collection of independent tests (sometimes including subtests). See any of the recently added tests to get a feel for it. test_progs' tests resemble real-world applications much closer than test_verifier or test_maps tests, so it serves both as a readable test and as an API demo.
Denisquoted
quoted
include/linux/bpf.h | 1 + kernel/bpf/hashtab.c | 38 +++++++++++++++++++++++++ kernel/bpf/syscall.c | 9 ++++++ tools/testing/selftests/bpf/test_maps.c | 7 +++++ 4 files changed, 55 insertions(+)[...]