FS#66260 - [linux] Add BTF support with config option CONFIG_DEBUG_INFO_BTF=y

Attached to Project: Arch Linux
Opened by Sardelli Tommaso (cippaciong) - Tuesday, 14 April 2020, 21:03 GMT
Last edited by Jan Alexander Steffens (heftig) - Sunday, 07 June 2020, 13:51 GMT
Task Type Feature Request
Category Kernel
Status Closed
Assigned To Tobias Powalowski (tpowa)
Jan Alexander Steffens (heftig)
Levente Polyak (anthraxx)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 6
Private No

Details

Description:
The current version of the linux package already supports eBPF through the usual config options like CONFIG_BPF, CONFIG_BPF_SYSCALL, CONFIG_BPF_JIT, etc. However, there isn't any support for the more recent BTF (BPF Type Format), which allows BPF developers to have debug info from their eBPF programs.
If possible, I would like to have BTF support added to the linux package with the additional config option CONFIG_DEBUG_INFO_BTF=y.

More information about BTF can be found at [0], [1], and [2]


Thank you all for your work :)

[0] https://www.kernel.org/doc/html/latest/bpf/btf.html
[1] https://facebookmicrosites.github.io/bpf/blog/2018/11/14/btf-enhancement.html
[2] https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html#btf
This task depends upon

Closed by  Jan Alexander Steffens (heftig)
Sunday, 07 June 2020, 13:51 GMT
Reason for closing:  Implemented
Additional comments about closing:  linux 5.7.1.arch1-1
Comment by Daniel Xu (dxu) - Saturday, 25 April 2020, 00:52 GMT
> which allows BPF developers to have debug info from their eBPF programs.

To clarify, this also allows BPF developers have access to _kernel_ debug information. It's much less heavy weight than DWARF (~1.5MB for BTF).

BTF enables all sorts of powerful features in bpftrace[0].

[0]: https://github.com/iovisor/bpftrace/blob/master/docs/reference_guide.md#15-kfunckretfunc-kernel-functions-tracing
Comment by Jan Alexander Steffens (heftig) - Wednesday, 29 April 2020, 09:13 GMT
I can't enable BTF debug info without also enabling un-split, un-reduced DWARF debug info.
Comment by Daniel Xu (dxu) - Wednesday, 29 April 2020, 15:09 GMT
The following configs seemed to work for me:

CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_REDUCED=y
CONFIG_DEBUG_INFO_SPLIT=y
# CONFIG_DEBUG_INFO_DWARF4 is not set
CONFIG_DEBUG_INFO_BTF=y

(compiled against upstream master)
Comment by Jan Alexander Steffens (heftig) - Wednesday, 29 April 2020, 15:39 GMT
How large are your packages, then?
Comment by Daniel Xu (dxu) - Wednesday, 29 April 2020, 16:03 GMT
> How large are your packages, then?
-rwxr-xr-x 1 daniel daniel 150M Apr 25 15:21 vmlinux

Not sure how to build arch kernel. Never tried. This is just `make vmlinux` from the
linux source tree.

I've attached the build config. It's just the `zcat /prog/config.gz` with the above
options flipped to enable BTF.

That being said, I don't think arch should be shipping DWARF symbols -- too heavy.
Maybe build BTF and the strip out the debug symbols, leaving BTF intact.
   .config (243 KiB)
Comment by Toke Høiland-Jørgensen (tohojo) - Thursday, 04 June 2020, 13:26 GMT
The attached change to PKGBUILD and config works for me.

$ ls -lh linux-5.7.arch1-2-x86_64.pkg.tar.xz
-rw-r--r-- 1 builder builder 72M Jun 4 12:28 linux-5.7.arch1-2-x86_64.pkg.tar.xz

(after booting that kernel)
$ ls /sys/kernel/btf
vmlinux
Comment by Jan Alexander Steffens (heftig) - Thursday, 04 June 2020, 16:46 GMT
I'll consider it for the next release, thanks.
Comment by Toke Høiland-Jørgensen (tohojo) - Thursday, 04 June 2020, 18:37 GMT
Awesome! BTW, just noticed that the kernel-headers package grew from 20M to 91M with this change. Seems to be the vmlinux file in that package that's the culprit (it's 551M after the patch), so I guess you may need to add a 'strip --strip-debug' to that as well. Let me know if you want to amend the patch with that.
Comment by Matt Pallissard (mattpallissard) - Sunday, 07 June 2020, 02:22 GMT
It's worth noting that with BTF enabled, `pahole` becomes a buildreq. There is an AUR package for it.

Loading...