bpf: Compute map_btf_id during build time
For now, the field 'map_btf_id' in 'struct bpf_map_ops' for all map types are computed during vmlinux-btf init: btf_parse_vmlinux() -> btf_vmlinux_map_ids_init() It will lookup the btf_type according to the 'map_btf_name' field in 'struct bpf_map_ops'. This process can be done during build time, thanks to Jiri's resolve_btfids. selftest of map_ptr has passed: $96 map_ptr:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Menglong Dong <imagedong@tencent.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
367590b7fc
commit
c317ab71fa
19 changed files with 62 additions and 129 deletions
|
|
@ -654,7 +654,7 @@ static void stack_map_free(struct bpf_map *map)
|
|||
put_callchain_buffers();
|
||||
}
|
||||
|
||||
static int stack_trace_map_btf_id;
|
||||
BTF_ID_LIST_SINGLE(stack_trace_map_btf_ids, struct, bpf_stack_map)
|
||||
const struct bpf_map_ops stack_trace_map_ops = {
|
||||
.map_meta_equal = bpf_map_meta_equal,
|
||||
.map_alloc = stack_map_alloc,
|
||||
|
|
@ -664,6 +664,5 @@ const struct bpf_map_ops stack_trace_map_ops = {
|
|||
.map_update_elem = stack_map_update_elem,
|
||||
.map_delete_elem = stack_map_delete_elem,
|
||||
.map_check_btf = map_check_no_btf,
|
||||
.map_btf_name = "bpf_stack_map",
|
||||
.map_btf_id = &stack_trace_map_btf_id,
|
||||
.map_btf_id = &stack_trace_map_btf_ids[0],
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue