All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Yonghong Song <yhs@fb.com>, Shung-Hsi Yu <shung-hsi.yu@suse.com>,
	bpf <bpf@vger.kernel.org>, Omar Sandoval <osandov@osandov.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: Question: missing vmlinux BTF variable declarations
Date: Tue, 3 May 2022 11:39:15 -0300	[thread overview]
Message-ID: <YnE+k33iUtLH7Lks@kernel.org> (raw)
In-Reply-To: <CAADnVQ+YuxB8gZGjx+RP=04z4SgYEmPjEjDa_=Q6HmUecxK8QQ@mail.gmail.com>

Em Fri, Apr 29, 2022 at 10:10:01AM -0700, Alexei Starovoitov escreveu:
> On Wed, Apr 27, 2022 at 11:43 AM Stephen Brennan <stephen.s.brennan@oracle.com> wrote:
> > [2]: https://github.com/brenns10/drgn/tree/kallsyms_plus_btf

> > Combining these three things, I've got a debugger which can open up a
> > vmcore _without DWARF debuginfo_ and allow you to print out typed
> > variable values. It just relies on BTF + kallsyms.

> > So the proof of concept is proven, and I'm quite excited about it!

> Exciting indeed. This is pretty cool.

Indeed!
 
> I'm afraid we cannot justify 2.5 Mb kernel memory increase for pure
> debugging. The existing vmlinux BTF is used by the kernel itself to
> validate bpf prog access.  bpf progs cannot access normal global vars.
> If/when they are we can reconsider.
 
> As an alternative path I think we could introduce hierarchical
> split BTF.

Which we already have in the form of BTF for modules that use vmlinux as
a base for common types.

> Currently vmlinux BTF and BTF of kernel modules is a tree
> of depth 2.

> We can keep such representation of BTFs and introduce a fake kernel
> module that contains kernel global vars.

pahole would generate a naked BTF just with variables and types not
present in the main vmlinux BTF and refer to it for all the other types.

> drgn can parse vmlinux BTF plus BTFs of all ko-s including fake one
> and obtain the same amount of debug info as if global vars
> were part of vmlinux BTF.

Right.

> Consuming 2.5Mb on demand via ko would be acceptable in some scenarios
> whereas unconditionally burning that much memory in vmlinux BTF (even
> optional via kconfig) is probably not.

And since it would be just an extra kernel module, the existing
packaging processes (in distros, embedded systems, etc) that care about
BTF would carry this without any modification to existing practices,
i.e. selecting CONFIG_DEBUG_INFO_BTF=y would bt default enable
CONFIG_DEBUG_INFO_GLOBAL_VARIABLES_BTF=y, which could be optionally
disabled by people not wanting to carry this extra info.

I.e. it would be always available but not always loaded.

> Ideally we structure BTFs as a multi level tree.  Where BTF with
> global vars and other non essential BTF info can be added to vmlinux
> BTF at run-time. BTF of kernel mods can add on top and mods can have
> split BTF too.

Yeah, reuses existing mechanizm, doesn't increase the kernel BTF
footprint by default, allows for debuggers, profilers, tracers, etc to
ask for extra info in the form of just loading btf_global_variables.ko.

- Arnaldo

  reply	other threads:[~2022-05-03 14:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09 23:20 Question: missing vmlinux BTF variable declarations Stephen Brennan
2022-03-14  7:09 ` Shung-Hsi Yu
2022-03-15  5:53   ` Yonghong Song
2022-03-15 16:37     ` Stephen Brennan
2022-03-15 17:58       ` Arnaldo Carvalho de Melo
2022-03-16 16:06         ` Stephen Brennan
2022-03-25 17:07           ` Andrii Nakryiko
2022-04-27 18:24             ` Stephen Brennan
2022-04-29 17:10               ` Alexei Starovoitov
2022-05-03 14:39                 ` Arnaldo Carvalho de Melo [this message]
2022-05-03 17:29                   ` Stephen Brennan
2022-05-03 22:31                     ` Alan Maguire
2022-05-10  0:10                       ` Andrii Nakryiko

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=YnE+k33iUtLH7Lks@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=osandov@osandov.com \
    --cc=shung-hsi.yu@suse.com \
    --cc=stephen.s.brennan@oracle.com \
    --cc=yhs@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.