From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Vamsi Kodavanty <vamsi@araalinetworks.com>,
rafaeldtinoco@gmail.com, bpf <bpf@vger.kernel.org>
Subject: Re: [BPF CO-RE clarification] Use CO-RE on older kernel versions.
Date: Thu, 4 Mar 2021 10:10:28 -0300 [thread overview]
Message-ID: <YEDcRMwRAD3Pxwhw@kernel.org> (raw)
In-Reply-To: <CAEf4BzZE_Ss7-cNdVpKJbC57mr2V_-OMcC9fvHw7XTntn3K2jA@mail.gmail.com>
Em Wed, Mar 03, 2021 at 11:05:44PM -0800, Andrii Nakryiko escreveu:
> On Wed, Mar 3, 2021 at 10:15 AM Rafael David Tinoco
> <rafaeldtinoco@ubuntu.com> wrote:
> >
> > > > From: Vamsi Kodavanty <vamsi@araalinetworks.com>
> > > > Date: Thu, 7 Jan 2021 17:31:11 -0800
> > > > To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
> > > > Cc: bpf <bpf@vger.kernel.org>
> > > >
> > > >
> > > > Right. Libbpf only supports a newer and safer way to attach to
> > > > kprobes. For your experiments, try to stick to tracepoints and you'll
> > > > have a better time.
> > > >
> > > > But it's another thing I've been meaning to add to libbpf for
> > > > supporting older kernels. I even have code written to do legacy kprobe
> > > > attachment, just need to find time to send a patch to add it as a
> > > > fallback for kernels that don't support new kprobe interface.
> >
> > Initially I'd like to thank you *a lot* for this thread, it helped me
> > creating:
> >
> > https://github.com/rafaeldtinoco/portablebpf
> >
> > showing up exactly what was discussed here AND I could run the same
> > binary in v4.15 and v.5.8 kernels as long as BTF was generated with:
> >
> > https://github.com/rafaeldtinoco/portablebpf/blob/master/patches/link-vmlinux.sh.patch
>
> I was wondering if it might be useful to have a script that would use
> pahole to do DWARF to BTF conversion for existing vmlinux image (e.g.,
> from /boot/vmlinux-$(uname -r)), assuming DWARF is in that vmlinux (or
> could be found somewhere nearby), and then would spit out only .BTF
> contents as a binary file, which can be passed to libbpf on
> bpf_object__open(). That seems useful and there have been at least a
> few cases where people tried to use CO-RE on old kernels
> pre-CONFIG_DEBUG_INFO_BTF, but were always confused by how to get that
> BTF data.
>
> [cc Arnaldo]
> It would also simplify things a bunch if pahole had an option to emit
> .BTF into a separate non-ELF file, instead of modifying vmlinux
> in-place. WDYT?
Sure, that is a nice addition, makes it more flexible to cover this
usecase.
- Arnaldo
> >
> > Specially the attach_kprobe_legacy() function:
> >
> > https://github.com/rafaeldtinoco/portablebpf/blob/master/mine.c#L31
> >
> > I wanted to reply here in case others also face this.
>
> Great, glad it worked out. It would be great if you could contribute
> legacy kprobe support for libbpf as a proper patch, since it probably
> would be useful for a bunch of other people stuck with old kernels.
>
> >
> > Only bad thing was kernel v4.15 missed global data support as showed in:
> >
> > https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md
> >
> > But using perf event was good enough for an example.
> >
> > - rafaeldtinoco
next prev parent reply other threads:[~2021-03-04 13:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 18:02 [BPF CO-RE clarification] Use CO-RE on older kernel versions Vamsi Kodavanty
2021-01-06 23:55 ` Andrii Nakryiko
2021-01-07 18:12 ` Vamsi Kodavanty
2021-01-07 18:52 ` Andrii Nakryiko
2021-01-07 22:45 ` Vamsi Kodavanty
2021-01-07 23:32 ` Andrii Nakryiko
2021-01-08 0:16 ` Vamsi Kodavanty
2021-01-08 1:31 ` Vamsi Kodavanty
2021-03-03 18:14 ` Rafael David Tinoco
2021-03-04 7:05 ` Andrii Nakryiko
2021-03-04 13:10 ` Arnaldo Carvalho de Melo [this message]
2021-03-05 6:32 ` Rafael David Tinoco
[not found] ` <67E3C788-2835-4793-8A9C-51C5D807C294@ubuntu.com>
2021-03-10 6:00 ` Fwd: " Rafael David Tinoco
2021-03-10 19:19 ` Andrii Nakryiko
2021-03-10 22:45 ` Rafael David Tinoco
2021-03-12 18:36 ` Andrii Nakryiko
2021-03-17 4:39 ` Rafael David Tinoco
2021-03-17 14:31 ` Rafael David Tinoco
2021-03-19 4:36 ` Andrii Nakryiko
2021-03-19 4:42 ` Rafael David Tinoco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YEDcRMwRAD3Pxwhw@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=andrii.nakryiko@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=rafaeldtinoco@gmail.com \
--cc=rafaeldtinoco@ubuntu.com \
--cc=vamsi@araalinetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).