summaryrefslogtreecommitdiffstats
path: root/kernel/bpf/core.c
diff options
context:
space:
mode:
authorYonghong Song <yonghong.song@linux.dev>2023-08-27 08:27:34 -0700
committerAlexei Starovoitov <ast@kernel.org>2023-09-08 08:42:17 -0700
commit41a5db8d8161457b121a03fde999ff6e00090ee2 (patch)
tree4474dade0ac40c98c45eff020a62cab62471f525 /kernel/bpf/core.c
parent3903802bb99a263a3c26422c3d30a121b1f6f939 (diff)
downloadlinux-41a5db8d8161457b121a03fde999ff6e00090ee2.tar.gz
linux-41a5db8d8161457b121a03fde999ff6e00090ee2.tar.bz2
linux-41a5db8d8161457b121a03fde999ff6e00090ee2.zip
bpf: Add support for non-fix-size percpu mem allocation
This is needed for later percpu mem allocation when the allocation is done by bpf program. For such cases, a global bpf_global_percpu_ma is added where a flexible allocation size is needed. Signed-off-by: Yonghong Song <yonghong.song@linux.dev> Link: https://lore.kernel.org/r/20230827152734.1995725-1-yonghong.song@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/core.c')
-rw-r--r--kernel/bpf/core.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 0f8f036d8bd1..95599df82ee4 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -64,8 +64,8 @@
#define OFF insn->off
#define IMM insn->imm
-struct bpf_mem_alloc bpf_global_ma;
-bool bpf_global_ma_set;
+struct bpf_mem_alloc bpf_global_ma, bpf_global_percpu_ma;
+bool bpf_global_ma_set, bpf_global_percpu_ma_set;
/* No hurry in this branch
*
@@ -2921,7 +2921,9 @@ static int __init bpf_global_ma_init(void)
ret = bpf_mem_alloc_init(&bpf_global_ma, 0, false);
bpf_global_ma_set = !ret;
- return ret;
+ ret = bpf_mem_alloc_init(&bpf_global_percpu_ma, 0, true);
+ bpf_global_percpu_ma_set = !ret;
+ return !bpf_global_ma_set || !bpf_global_percpu_ma_set;
}
late_initcall(bpf_global_ma_init);
#endif