bpf: Compute map_btf_id during build time
authorMenglong Dong <imagedong@tencent.com>
Mon, 25 Apr 2022 13:32:47 +0000 (21:32 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 26 Apr 2022 18:35:21 +0000 (11:35 -0700)
commitc317ab71facc2cd0a94145973318a4c914e11acc
tree62a429e18068504f46d091d8423e9c4f39d633e7
parent367590b7fccc2c317026abe7d29923322d959781
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>
19 files changed:
include/linux/bpf.h
kernel/bpf/arraymap.c
kernel/bpf/bloom_filter.c
kernel/bpf/bpf_inode_storage.c
kernel/bpf/bpf_struct_ops.c
kernel/bpf/bpf_task_storage.c
kernel/bpf/btf.c
kernel/bpf/cpumap.c
kernel/bpf/devmap.c
kernel/bpf/hashtab.c
kernel/bpf/local_storage.c
kernel/bpf/lpm_trie.c
kernel/bpf/queue_stack_maps.c
kernel/bpf/reuseport_array.c
kernel/bpf/ringbuf.c
kernel/bpf/stackmap.c
net/core/bpf_sk_storage.c
net/core/sock_map.c
net/xdp/xskmap.c