diff options
author | Martin KaFai Lau <martin.lau@kernel.org> | 2023-03-22 14:52:42 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-03-25 19:52:51 -0700 |
commit | e65a5c6edbc6ca4853e6076bd81db1a410592a09 (patch) | |
tree | 48c2cb3a361df556443d7e73d74a45c1afdbc31d /net | |
parent | e99360762a9cbd93bf1d352e90df5df78daa2f90 (diff) | |
download | linux-stable-e65a5c6edbc6ca4853e6076bd81db1a410592a09.tar.gz linux-stable-e65a5c6edbc6ca4853e6076bd81db1a410592a09.tar.bz2 linux-stable-e65a5c6edbc6ca4853e6076bd81db1a410592a09.zip |
bpf: Add a few bpf mem allocator functions
This patch adds a few bpf mem allocator functions which will
be used in the bpf_local_storage in a later patch.
bpf_mem_cache_alloc_flags(..., gfp_t flags) is added. When the
flags == GFP_KERNEL, it will fallback to __alloc(..., GFP_KERNEL).
bpf_local_storage knows its running context is sleepable (GFP_KERNEL)
and provides a better guarantee on memory allocation.
bpf_local_storage has some uncommon cases that its selem
cannot be reused immediately. It handles its own
rcu_head and goes through a rcu_trace gp and then free it.
bpf_mem_cache_raw_free() is added for direct free purpose
without leaking the LLIST_NODE_SZ internal knowledge.
During free time, the 'struct bpf_mem_alloc *ma' is no longer
available. However, the caller should know if it is
percpu memory or not and it can call different raw_free functions.
bpf_local_storage does not support percpu value, so only
the non-percpu 'bpf_mem_cache_raw_free()' is added in
this patch.
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://lore.kernel.org/r/20230322215246.1675516-2-martin.lau@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'net')
0 files changed, 0 insertions, 0 deletions