Skip to contentSkip to conversation

bpf: Is it possible to move .BTF data into a module

DISCUSSION Vitaly Chikunov 4 participants 5 messages Nov 4, 2022 BPF

lore
Share & tools
lore
#0 lore raw

Hi,

We need to reduce kernel size for aarch64, because it does not fit into U-Boot loader on Raspberry Pi (due to it having fdt_addr_r=0x02600000) and one of big ELF sections in vmlinuz is .BTF taking around 5MB. Compression does not help because on aarch64 kernels are uncompressed[1].

Is it theoretically possible to make sysfs_btf a module?

Yes this will reduce tracing at boot times, but at least it will give option for occasional tracing after boot.

Thanks,

[1] https://www.kernel.org/doc/Documentation/arm64/booting.txt #3.

#1 lore raw
Quoted 10 lines · Vitaly Chikunov

Hi,

We need to reduce kernel size for aarch64, because it does not fit into U-Boot loader on Raspberry Pi (due to it having fdt_addr_r=0x02600000) and one of big ELF sections in vmlinuz is .BTF taking around 5MB. Compression does not help because on aarch64 kernels are uncompressed[1].

Is it theoretically possible to make sysfs_btf a module?

I think so, it may need some refactoring and changes
but, yeah, in theory, the module could ship with the kernel's BTF information which can then be initialized by the module.

Curious to see what others think as well.

Quoted 7 lines

Yes this will reduce tracing at boot times, but at least it will give option for occasional tracing after boot.

Thanks,

[1] https://www.kernel.org/doc/Documentation/arm64/booting.txt #3.

#2 lore raw
Quoted 11 lines · KP Singh
Quoted 9 lines · Vitaly Chikunov

Hi,

We need to reduce kernel size for aarch64, because it does not fit into U-Boot loader on Raspberry Pi (due to it having fdt_addr_r=0x02600000) and one of big ELF sections in vmlinuz is .BTF taking around 5MB. Compression does not help because on aarch64 kernels are uncompressed[1].

Quoted 7 lines
Quoted 1 line

Is it theoretically possible to make sysfs_btf a module?

I think so, it may need some refactoring and changes
but, yeah, in theory, the module could ship with the kernel's BTF information which can then be initialized by the module.

Curious to see what others think as well.

Yeah. That request came up a few times. Whoever has cycles to work on it... please go ahead :)

#3 lore raw
Quoted 14 lines · Alexei Starovoitov
Quoted 13 lines · KP Singh
Quoted 10 lines · Vitaly Chikunov

Hi,

We need to reduce kernel size for aarch64, because it does not fit into U-Boot loader on Raspberry Pi (due to it having fdt_addr_r=0x02600000) and one of big ELF sections in vmlinuz is .BTF taking around 5MB. Compression does not help because on aarch64 kernels are uncompressed[1].

Is it theoretically possible to make sysfs_btf a module?

Quoted 9 lines
Quoted 5 lines

I think so, it may need some refactoring and changes
but, yeah, in theory, the module could ship with the kernel's BTF information which can then be initialized by the module.

Curious to see what others think as well.

Yeah. That request came up a few times. Whoever has cycles to work on it... please go ahead :)

We've experimented with this a bit for the global variable patch series, where global variable BTF is a tristate config parameter, and if set to 'm' the BTF for variables ends up in vmlinux_btf_extra.ko instead (patch series forthcoming; it was stuck behind the dedup issues which took a while to uncover). One approach would be to extend that scheme such that CONFIG_DEBUG_INFO_BTF=m I guess?

The only thing that might require change is the name; vmlinux_btf might be a more appropriate module name than vmlinux_btf_extra perhaps? Thanks!

Alan

#4 lore raw
Quoted 26 lines · Alan Maguire
Quoted 14 lines · Alexei Starovoitov
Quoted 13 lines · KP Singh
Quoted 10 lines · Vitaly Chikunov

Hi,

We need to reduce kernel size for aarch64, because it does not fit into U-Boot loader on Raspberry Pi (due to it having fdt_addr_r=0x02600000) and one of big ELF sections in vmlinuz is .BTF taking around 5MB. Compression does not help because on aarch64 kernels are uncompressed[1].

Is it theoretically possible to make sysfs_btf a module?

Quoted 9 lines
Quoted 5 lines

I think so, it may need some refactoring and changes
but, yeah, in theory, the module could ship with the kernel's BTF information which can then be initialized by the module.

Curious to see what others think as well.

Yeah. That request came up a few times. Whoever has cycles to work on it... please go ahead :)

Quoted 7 lines

We've experimented with this a bit for the global variable patch series, where global variable BTF is a tristate config parameter, and if set to 'm' the BTF for variables ends up in vmlinux_btf_extra.ko instead (patch series forthcoming; it was stuck behind the dedup issues which took a while to uncover). One approach would be to extend that scheme such that CONFIG_DEBUG_INFO_BTF=m I guess?

makes sense.

Quoted 3 lines

The only thing that might require change is the name; vmlinux_btf might be a more appropriate module name than vmlinux_btf_extra perhaps? Thanks!

yeah. vmlinux_btf as a module name should work.
libbpf can be taught to look at /sys/kernel/btf/vmlinux and vmlinux_btf.