Re: [iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
"Daniel Xu" writes: > On Sun, Feb 28, 2021, at 12:07 PM, bg.salunk...@gmail.com wrote: >> Hi, >> >> I'm looking into BTF and it's use case. Based on the document I >> understood to run BPF programs across different kernel versions, it >> needs to build with libbpf which depends on the BTF information. >> Now to enable/to have BTF information on any Kernel, the kernel needs >> to be re-build with "" flag. >> >> I can see the BTF support in Linus introduced from *kernel version >> 5.1.0 >> (*https://www.kernel.org/doc/html/v5.1/bpf/btf.html?highlight=btf) >> however I can still see the BTF information(/sys/kernel/btf/vmlinux) on >> my 4.18.0-193.28.1.el8_2.x86_64 kernel. > > What distro are you using? Your distro probably backported BTF > support. Yeah, that's a RHEL version number (RHEL8.2 in this case, as seen by the "el8_2" bit). Which means that as far as features are concerned, the 4.18 version number is basically a complete fiction at this point. For BPF we basically backport everything, IIRC we made it up to upstream kernel 5.4 for RHEL8.2... -Toke -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1973): https://lists.iovisor.org/g/iovisor-dev/message/1973 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
On Tue, Mar 2, 2021 at 08:22 PM, Andrii Nakryiko wrote: > > On Tue, Mar 2, 2021 at 4:42 PM wrote: > >> Thanks Andrii, for detailed answer. >> Yes you are right, I'm looking for CO-RE. Basically I'm trying to build >> the eBPF program which can run on any linux kernel version using libbpf >> >> What I understood from your blog >> https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html >> (Thanks for in depth blog post, appreciate it), to work libbpf based >> program >> the BTF information should be available on the running host. Is my >> understanding correct? > > Yes, correct. Thank you for confirming! > > >> Btw, Is there any document to generate BTF information for a linux kernel? >> Or Is there a way to generate BTF info for running kernel i.e. at runtime >> and not at compile time? Thanks! > > Yes, you can, if you have vmlinux image with DWARF information in it. > You can use pahole tool like this to add .BTF section to vmlinux > image: > > pahole -J > > You most probably would want to make a local copy of vmlinux image, of > course. After that you can pass the path to that vmlinux with embedded > .BTF to libbpf to use for CO-RE relocations. See [0] for recent > discussion of the exact same topic. See also patch [1] that was aiming > to make this scenario better in libbpf (unfortunately it hasn't landed > yet, but it is pretty close to being done, so shouldn't be a problem > for you to pick up, if necessary). > > This is certainly not the most straightforward and easiest path, but > if you want to get CO-RE working with older kernel for which you don't > have much control, it is definitely a possible way (as long as you > have DWARF, which is used to produce BTF for vmlinux). > > [0] > https://lore.kernel.org/bpf/CAEf4BzbJZLjNoiK8_VfeVg_Vrg=9iYFv+po-38SMe=UzwDKJ=q...@mail.gmail.com/ > > [1] > https://lore.kernel.org/bpf/b8801f77-37e8-4ef8-8994-d366d4816...@araalinetworks.com/ > > > Go it. I'm following the discussion thread and patch. Thank you so much for your time. -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1970): https://lists.iovisor.org/g/iovisor-dev/message/1970 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
On Tue, Mar 2, 2021 at 4:42 PM wrote: > > Thanks Andrii, for detailed answer. > Yes you are right, I'm looking for CO-RE. Basically I'm trying to build the > eBPF program which can run on any linux kernel version using libbpf > > What I understood from your blog > https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html > (Thanks for in depth blog post, appreciate it), to work libbpf based program > the BTF information should be available on the running host. Is my > understanding correct? Yes, correct. > > Btw, Is there any document to generate BTF information for a linux kernel? > Or Is there a way to generate BTF info for running kernel i.e. at runtime and > not at compile time? Thanks! Yes, you can, if you have vmlinux image with DWARF information in it. You can use pahole tool like this to add .BTF section to vmlinux image: pahole -J You most probably would want to make a local copy of vmlinux image, of course. After that you can pass the path to that vmlinux with embedded .BTF to libbpf to use for CO-RE relocations. See [0] for recent discussion of the exact same topic. See also patch [1] that was aiming to make this scenario better in libbpf (unfortunately it hasn't landed yet, but it is pretty close to being done, so shouldn't be a problem for you to pick up, if necessary). This is certainly not the most straightforward and easiest path, but if you want to get CO-RE working with older kernel for which you don't have much control, it is definitely a possible way (as long as you have DWARF, which is used to produce BTF for vmlinux). [0] https://lore.kernel.org/bpf/CAEf4BzbJZLjNoiK8_VfeVg_Vrg=9iYFv+po-38SMe=UzwDKJ=q...@mail.gmail.com/ [1] https://lore.kernel.org/bpf/b8801f77-37e8-4ef8-8994-d366d4816...@araalinetworks.com/ > -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1969): https://lists.iovisor.org/g/iovisor-dev/message/1969 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
Thanks Andrii, for detailed answer. Yes you are right, I'm looking for CO-RE. Basically I'm trying to build the eBPF program which can run on any linux kernel version using libbpf What I understood from your blog https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html (Thanks for in depth blog post, appreciate it), to work libbpf based program the BTF information should be available on the running host. Is my understanding correct? Btw, Is there any document to generate BTF information for a linux kernel? Or Is there a way to generate BTF info for running kernel i.e. at runtime and not at compile time? Thanks! -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1968): https://lists.iovisor.org/g/iovisor-dev/message/1968 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
"Andrii Nakryiko" writes: > On Sun, Feb 28, 2021 at 12:37 PM wrote: >> >> [Edited Message Follows] >> >> Hi, >> >> I'm looking into BTF and it's use case. Based on the document I understood >> to run BPF programs across different kernel versions, it needs to build with >> libbpf which depends on the BTF information. >> Now to enable/to have BTF information on any Kernel, the kernel needs to be >> re-build with "" flag. >> >> I can see the BTF support in Linux introduced from kernel version 5.1.0 >> (https://www.kernel.org/doc/html/v5.1/bpf/btf.html?highlight=btf) >> however I can still see the BTF information(/sys/kernel/btf/vmlinux) on my >> 4.18.0-193.28.1.el8_2.x86_64 kernel. >> >> I'm little confused here how old kernel can generate BTF info if the was >> support added recently. >> >> Can I get information about oldest linux kernel version that can support BTF? > > /sys/kernel/btf/vmlinux appeared in 5.4 kernel (upstream version). If > you see it on 4.18, that means someone backported the changes. Yeah, that looks like a RHEL/CentOS kernel version number, which means the 4.18 bit is mostly fiction at this point (at least as far as BPF is concerned). IIRC we backported up to upstream kernel 5.4 for RHEL 8.2, which seems to be what you're running (from the el8_2 bit of the version), and I guess that fits with the availability of /sys/kernel/btf/vmlinux -Toke -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1967): https://lists.iovisor.org/g/iovisor-dev/message/1967 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
On Sun, Feb 28, 2021 at 12:37 PM wrote: > > [Edited Message Follows] > > Hi, > > I'm looking into BTF and it's use case. Based on the document I understood to > run BPF programs across different kernel versions, it needs to build with > libbpf which depends on the BTF information. > Now to enable/to have BTF information on any Kernel, the kernel needs to be > re-build with "" flag. > > I can see the BTF support in Linux introduced from kernel version 5.1.0 > (https://www.kernel.org/doc/html/v5.1/bpf/btf.html?highlight=btf) > however I can still see the BTF information(/sys/kernel/btf/vmlinux) on my > 4.18.0-193.28.1.el8_2.x86_64 kernel. > > I'm little confused here how old kernel can generate BTF info if the was > support added recently. > > Can I get information about oldest linux kernel version that can support BTF? /sys/kernel/btf/vmlinux appeared in 5.4 kernel (upstream version). If you see it on 4.18, that means someone backported the changes. But for BPF CO-RE (which I assume is what you are referring to) to work, kernel itself doesn't need to "support BTF", it just needs to have .BTF data built-in inside its vmlinux binary image, and that image needs to be in one of the supported locations (see [0]). Starting from 5.2 kernel CONFIG_DEBUG_INTO_BTF=y is supported with adds .BTF section as part of the kernel build process. But one could technically add .BTF by using pahole tool (part of dwarves package) even before that, as long as vmlinux image contains DWARF information. So in short, the easiest way is to get the latest kernel you can. But with enough persistence and effort you can get kernel BTF embedded for pretty much any kernel version. [0] https://github.com/libbpf/libbpf/blob/master/src/btf.c#L4589-L4598 > > > -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1966): https://lists.iovisor.org/g/iovisor-dev/message/1966 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
Re: [iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
bg.salunk...@gmail.com asked: > Can I get information about oldest linux kernel version that can support BTF? The basic support appears to have been added by commit e83b9f55448afce3fe1abcd1d10db9584f8042a6 Author: Andrii Nakryiko Date: Tue Apr 2 09:49:50 2019 -0700 kbuild: add ability to generate BTF type info for vmlinux The inquiry "git branch --contains e83b9f55448a" will tell you which of your branches contains this commit. Hope this helps, Alison Chaiken Aurora Innovation -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1965): https://lists.iovisor.org/g/iovisor-dev/message/1965 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
[Edited Message Follows] Hi, I'm looking into BTF and it's use case. Based on the document I understood to run BPF programs across different kernel versions, it needs to build with libbpf which depends on the BTF information. Now to enable/to have BTF information on any Kernel, the kernel needs to be re-build with "" flag. I can see the BTF support in Linux introduced from *kernel version 5.1.0 (* https://www.kernel.org/doc/html/v5.1/bpf/btf.html?highlight=btf ) however I can still see the BTF information (/sys/kernel/btf/vmlinux) on my 4.18.0-193.28.1.el8_2.x86_64 kernel. I'm little confused here how old kernel can generate BTF info if the was support added recently. Can I get information about oldest linux kernel version that can support BTF? -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1964): https://lists.iovisor.org/g/iovisor-dev/message/1964 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[iovisor-dev] Which is oldest linux kernel version that can support BTF? #bcc
Hi, I'm looking into BTF and it's use case. Based on the document I understood to run BPF programs across different kernel versions, it needs to build with libbpf which depends on the BTF information. Now to enable/to have BTF information on any Kernel, the kernel needs to be re-build with "" flag. I can see the BTF support in Linus introduced from *kernel version 5.1.0 (* https://www.kernel.org/doc/html/v5.1/bpf/btf.html?highlight=btf ) however I can still see the BTF information (/sys/kernel/btf/vmlinux) on my 4.18.0-193.28.1.el8_2.x86_64 kernel. I'm little confused here how old kernel can generate BTF info if the was support added recently. Can I get information about oldest linux kernel version that can support BTF? -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#1964): https://lists.iovisor.org/g/iovisor-dev/message/1964 Mute This Topic: https://lists.iovisor.org/mt/80980657/21656 Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc Group Owner: iovisor-dev+ow...@lists.iovisor.org Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-