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

Configure Feed

Select the types of activity you want to include in your feed.

btf: Add BTF kind layout encoding to UAPI

BTF kind layouts provide information to parse BTF kinds. By separating
parsing BTF from using all the information it provides, we allow BTF
to encode new features even if they cannot be used by readers. This
will be helpful in particular for cases where older tools are used
to parse newer BTF with kinds the older tools do not recognize;
the BTF can still be parsed in such cases using kind layout.

The intent is to support encoding of kind layouts optionally so that
tools like pahole can add this information. For each kind, we record

- length of singular element following struct btf_type
- length of each of the btf_vlen() elements following
- a (currently unused) flags field

The ideas here were discussed at [1], [2]; hence

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260326145444.2076244-2-alan.maguire@oracle.com

[1] https://lore.kernel.org/bpf/CAEf4BzYjWHRdNNw4B=eOXOs_ONrDwrgX4bn=Nuc1g8JPFC34MA@mail.gmail.com/
[2] https://lore.kernel.org/bpf/20230531201936.1992188-1-alan.maguire@oracle.com/

authored by

Alan Maguire and committed by
Andrii Nakryiko
222edc84 400ff899

+24
+12
include/uapi/linux/btf.h
··· 8 8 #define BTF_MAGIC 0xeB9F 9 9 #define BTF_VERSION 1 10 10 11 + /* 12 + * BTF layout section consists of a struct btf_layout for each known 13 + * kind at BTF encoding time. 14 + */ 15 + struct btf_layout { 16 + __u8 info_sz; /* size of singular element after btf_type */ 17 + __u8 elem_sz; /* size of each of btf_vlen(t) elements */ 18 + __u16 flags; /* currently unused */ 19 + }; 20 + 11 21 struct btf_header { 12 22 __u16 magic; 13 23 __u8 version; ··· 29 19 __u32 type_len; /* length of type section */ 30 20 __u32 str_off; /* offset of string section */ 31 21 __u32 str_len; /* length of string section */ 22 + __u32 layout_off; /* offset of layout section */ 23 + __u32 layout_len; /* length of layout section */ 32 24 }; 33 25 34 26 /* Max # of type identifier */
+12
tools/include/uapi/linux/btf.h
··· 8 8 #define BTF_MAGIC 0xeB9F 9 9 #define BTF_VERSION 1 10 10 11 + /* 12 + * BTF layout section consists of a struct btf_layout for each known 13 + * kind at BTF encoding time. 14 + */ 15 + struct btf_layout { 16 + __u8 info_sz; /* size of singular element after btf_type */ 17 + __u8 elem_sz; /* size of each of btf_vlen(t) elements */ 18 + __u16 flags; /* currently unused */ 19 + }; 20 + 11 21 struct btf_header { 12 22 __u16 magic; 13 23 __u8 version; ··· 29 19 __u32 type_len; /* length of type section */ 30 20 __u32 str_off; /* offset of string section */ 31 21 __u32 str_len; /* length of string section */ 22 + __u32 layout_off; /* offset of layout section */ 23 + __u32 layout_len; /* length of layout section */ 32 24 }; 33 25 34 26 /* Max # of type identifier */