Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/bpf: Sync btf_ids.h to tools

Has been slowly getting out of sync, let's update it.

resolve_btfids usage has been updated to match the header changes.

Also bring new parts of tools/include/uapi/linux/bpf.h.

Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/20220628174314.1216643-8-sdf@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Stanislav Fomichev and committed by
Alexei Starovoitov
3b34bcb9 9113d7e4

+32 -8
+28 -7
tools/include/linux/btf_ids.h
··· 73 73 __BTF_ID_LIST(name, local) \ 74 74 extern u32 name[]; 75 75 76 - #define BTF_ID_LIST_GLOBAL(name) \ 76 + #define BTF_ID_LIST_GLOBAL(name, n) \ 77 77 __BTF_ID_LIST(name, globl) 78 78 79 79 /* The BTF_ID_LIST_SINGLE macro defines a BTF_ID_LIST with ··· 81 81 */ 82 82 #define BTF_ID_LIST_SINGLE(name, prefix, typename) \ 83 83 BTF_ID_LIST(name) \ 84 + BTF_ID(prefix, typename) 85 + #define BTF_ID_LIST_GLOBAL_SINGLE(name, prefix, typename) \ 86 + BTF_ID_LIST_GLOBAL(name, 1) \ 84 87 BTF_ID(prefix, typename) 85 88 86 89 /* ··· 146 143 147 144 #else 148 145 149 - #define BTF_ID_LIST(name) static u32 name[5]; 146 + #define BTF_ID_LIST(name) static u32 __maybe_unused name[5]; 150 147 #define BTF_ID(prefix, name) 151 148 #define BTF_ID_UNUSED 152 - #define BTF_ID_LIST_GLOBAL(name) u32 name[1]; 153 - #define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 name[1]; 154 - #define BTF_SET_START(name) static struct btf_id_set name = { 0 }; 155 - #define BTF_SET_START_GLOBAL(name) static struct btf_id_set name = { 0 }; 149 + #define BTF_ID_LIST_GLOBAL(name, n) u32 __maybe_unused name[n]; 150 + #define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 __maybe_unused name[1]; 151 + #define BTF_ID_LIST_GLOBAL_SINGLE(name, prefix, typename) u32 __maybe_unused name[1]; 152 + #define BTF_SET_START(name) static struct btf_id_set __maybe_unused name = { 0 }; 153 + #define BTF_SET_START_GLOBAL(name) static struct btf_id_set __maybe_unused name = { 0 }; 156 154 #define BTF_SET_END(name) 157 155 158 156 #endif /* CONFIG_DEBUG_INFO_BTF */ ··· 176 172 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock) \ 177 173 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock) \ 178 174 BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock) \ 179 - BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock) 175 + BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock) \ 176 + BTF_SOCK_TYPE(BTF_SOCK_TYPE_UNIX, unix_sock) \ 177 + BTF_SOCK_TYPE(BTF_SOCK_TYPE_MPTCP, mptcp_sock) \ 178 + BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCKET, socket) 180 179 181 180 enum { 182 181 #define BTF_SOCK_TYPE(name, str) name, ··· 190 183 191 184 extern u32 btf_sock_ids[]; 192 185 #endif 186 + 187 + #define BTF_TRACING_TYPE_xxx \ 188 + BTF_TRACING_TYPE(BTF_TRACING_TYPE_TASK, task_struct) \ 189 + BTF_TRACING_TYPE(BTF_TRACING_TYPE_FILE, file) \ 190 + BTF_TRACING_TYPE(BTF_TRACING_TYPE_VMA, vm_area_struct) 191 + 192 + enum { 193 + #define BTF_TRACING_TYPE(name, type) name, 194 + BTF_TRACING_TYPE_xxx 195 + #undef BTF_TRACING_TYPE 196 + MAX_BTF_TRACING_TYPE, 197 + }; 198 + 199 + extern u32 btf_tracing_ids[]; 193 200 194 201 #endif
+3
tools/include/uapi/linux/bpf.h
··· 1432 1432 __u32 attach_flags; 1433 1433 __aligned_u64 prog_ids; 1434 1434 __u32 prog_cnt; 1435 + __aligned_u64 prog_attach_flags; /* output: per-program attach_flags */ 1435 1436 } query; 1436 1437 1437 1438 struct { /* anonymous struct used by BPF_RAW_TRACEPOINT_OPEN command */ ··· 6077 6076 __u64 run_cnt; 6078 6077 __u64 recursion_misses; 6079 6078 __u32 verified_insns; 6079 + __u32 attach_btf_obj_id; 6080 + __u32 attach_btf_id; 6080 6081 } __attribute__((aligned(8))); 6081 6082 6082 6083 struct bpf_map_info {
+1 -1
tools/testing/selftests/bpf/prog_tests/resolve_btfids.c
··· 44 44 BTF_ID(func, func) 45 45 46 46 extern __u32 test_list_global[]; 47 - BTF_ID_LIST_GLOBAL(test_list_global) 47 + BTF_ID_LIST_GLOBAL(test_list_global, 1) 48 48 BTF_ID_UNUSED 49 49 BTF_ID(typedef, S) 50 50 BTF_ID(typedef, T)