diff options
author | Alexei Starovoitov <ast@kernel.org> | 2022-09-02 14:10:52 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2022-09-05 15:33:06 +0200 |
commit | 4ab67149f3c6e97c5c506a726f0ebdec38241679 (patch) | |
tree | cef5bd8102787075a2766028587d49a917053433 /kernel/bpf/hashtab.c | |
parent | bpf: Batch call_rcu callbacks instead of SLAB_TYPESAFE_BY_RCU. (diff) | |
download | linux-dev-4ab67149f3c6e97c5c506a726f0ebdec38241679.tar.xz linux-dev-4ab67149f3c6e97c5c506a726f0ebdec38241679.zip |
bpf: Add percpu allocation support to bpf_mem_alloc.
Extend bpf_mem_alloc to cache free list of fixed size per-cpu allocations.
Once such cache is created bpf_mem_cache_alloc() will return per-cpu objects.
bpf_mem_cache_free() will free them back into global per-cpu pool after
observing RCU grace period.
per-cpu flavor of bpf_mem_alloc is going to be used by per-cpu hash maps.
The free list cache consists of tuples { llist_node, per-cpu pointer }
Unlike alloc_percpu() that returns per-cpu pointer
the bpf_mem_cache_alloc() returns a pointer to per-cpu pointer and
bpf_mem_cache_free() expects to receive it back.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220902211058.60789-11-alexei.starovoitov@gmail.com
Diffstat (limited to 'kernel/bpf/hashtab.c')
-rw-r--r-- | kernel/bpf/hashtab.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index 0d888a90a805..70b02ff4445e 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -607,7 +607,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) goto free_prealloc; } } else { - err = bpf_mem_alloc_init(&htab->ma, htab->elem_size); + err = bpf_mem_alloc_init(&htab->ma, htab->elem_size, false); if (err) goto free_map_locked; } |