summaryrefslogtreecommitdiffstats
path: root/include/linux/bpf_mem_alloc.h
diff options
context:
space:
mode:
authorHou Tao <houtao1@huawei.com>2023-02-16 10:48:21 +0800
committerAlexei Starovoitov <ast@kernel.org>2023-02-22 12:59:32 -0800
commit5d5de3a431d87ac51d43da8d796891d014975ab7 (patch)
treed9c0e756cf0fc202271c07a39b9ea57030da69db /include/linux/bpf_mem_alloc.h
parentdbd8d22863e83ee2834642e4cfd3bdacb8a1c975 (diff)
downloadlinux-stable-5d5de3a431d87ac51d43da8d796891d014975ab7.tar.gz
linux-stable-5d5de3a431d87ac51d43da8d796891d014975ab7.tar.bz2
linux-stable-5d5de3a431d87ac51d43da8d796891d014975ab7.zip
bpf: Only allocate one bpf_mem_cache for bpf_cpumask_ma
The size of bpf_cpumask is fixed, so there is no need to allocate many bpf_mem_caches for bpf_cpumask_ma, just one bpf_mem_cache is enough. Also add comments for bpf_mem_alloc_init() in bpf_mem_alloc.h to prevent future miuse. Signed-off-by: Hou Tao <houtao1@huawei.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20230216024821.2202916-1-houtao@huaweicloud.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux/bpf_mem_alloc.h')
-rw-r--r--include/linux/bpf_mem_alloc.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/bpf_mem_alloc.h b/include/linux/bpf_mem_alloc.h
index 3e164b8efaa9..a7104af61ab4 100644
--- a/include/linux/bpf_mem_alloc.h
+++ b/include/linux/bpf_mem_alloc.h
@@ -14,6 +14,13 @@ struct bpf_mem_alloc {
struct work_struct work;
};
+/* 'size != 0' is for bpf_mem_alloc which manages fixed-size objects.
+ * Alloc and free are done with bpf_mem_cache_{alloc,free}().
+ *
+ * 'size = 0' is for bpf_mem_alloc which manages many fixed-size objects.
+ * Alloc and free are done with bpf_mem_{alloc,free}() and the size of
+ * the returned object is given by the size argument of bpf_mem_alloc().
+ */
int bpf_mem_alloc_init(struct bpf_mem_alloc *ma, int size, bool percpu);
void bpf_mem_alloc_destroy(struct bpf_mem_alloc *ma);