[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <04403b43-3a08-e63e-729e-5f9e66ca0dc2@iogearbox.net>
Date: Mon, 18 Nov 2019 14:50:42 +0100
From: Daniel Borkmann <daniel@...earbox.net>
To: Andrii Nakryiko <andriin@...com>, bpf@...r.kernel.org,
netdev@...r.kernel.org, ast@...com
Cc: andrii.nakryiko@...il.com, kernel-team@...com
Subject: Re: [PATCH v6 bpf-next 0/5] Add support for memory-mapping BPF array
maps
On 11/17/19 6:28 PM, Andrii Nakryiko wrote:
> This patch set adds ability to memory-map BPF array maps (single- and
> multi-element). The primary use case is memory-mapping BPF array maps, created
> to back global data variables, created by libbpf implicitly. This allows for
> much better usability, along with avoiding syscalls to read or update data
> completely.
>
> Due to memory-mapping requirements, BPF array map that is supposed to be
> memory-mapped, has to be created with special BPF_F_MMAPABLE attribute, which
> triggers slightly different memory allocation strategy internally. See
> patch 1 for details.
>
> Libbpf is extended to detect kernel support for this flag, and if supported,
> will specify it for all global data maps automatically.
>
> Patch #1 refactors bpf_map_inc() and converts bpf_map's refcnt to atomic64_t
> to make refcounting never fail. Patch #2 does similar refactoring for
> bpf_prog_add()/bpf_prog_inc().
>
> v5->v6:
> - add back uref counting (Daniel);
>
> v4->v5:
> - change bpf_prog's refcnt to atomic64_t (Daniel);
>
> v3->v4:
> - add mmap's open() callback to fix refcounting (Johannes);
> - switch to remap_vmalloc_pages() instead of custom fault handler (Johannes);
> - converted bpf_map's refcnt/usercnt into atomic64_t;
> - provide default bpf_map_default_vmops handling open/close properly;
>
> v2->v3:
> - change allocation strategy to avoid extra pointer dereference (Jakub);
>
> v1->v2:
> - fix map lookup code generation for BPF_F_MMAPABLE case;
> - prevent BPF_F_MMAPABLE flag for all but plain array map type;
> - centralize ref-counting in generic bpf_map_mmap();
> - don't use uref counting (Alexei);
> - use vfree() directly;
> - print flags with %x (Song);
> - extend tests to verify bpf_map_{lookup,update}_elem() logic as well.
>
> Andrii Nakryiko (5):
> bpf: switch bpf_map ref counter to atomic64_t so bpf_map_inc() never
> fails
> bpf: convert bpf_prog refcnt to atomic64_t
> bpf: add mmap() support for BPF_MAP_TYPE_ARRAY
> libbpf: make global data internal arrays mmap()-able, if possible
> selftests/bpf: add BPF_TYPE_MAP_ARRAY mmap() tests
>
Applied, thanks!
Powered by blists - more mailing lists