public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: Stephen Brennan <stephen@brennan.io>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexei Starovoitov <alexei.starovoitov@gmail.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>,
	Stephen Brennan <stephen.s.brennan@oracle.com>
Subject: Re: Question: missing vmlinux BTF variable declarations
Date: Tue, 3 May 2022 23:31:31 +0100 (IST)	[thread overview]
Message-ID: <alpine.LRH.2.23.451.2205032254390.10133@MyRouter> (raw)
In-Reply-To: <87zgjy8qzi.fsf@brennan.io>

On Tue, 3 May 2022, Stephen Brennan wrote:

> >> 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.
> 
> I see what you mean. It does sound a bit frustrating to have an
> additional BTF module to augment every external module, which would be
> the third level of that tree.
> 
> We'll need to allocate more module structs and pages within the kernel
> for that data, I wonder whether it would be cheaper for the
> "non-essential" module BTF to just reside in the same BTF section of
> that module.
> 
> I suppose I can run my modified pahole on some sample modules and see
> the BTF size difference, rather than just speculating, I'll do that in a
> follow-up here.
> 
> > 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.
> 
> I agree, this is a quite elegant solution. Though it'll require a fair
> bit of work to achieve, I do think it's important to keep the footprint
> down. One thing I'd like to see in this world is a way to instruct the
> kernel that "I always want the non-essential BTF loaded", maybe via
> cmdline or sysctl. This way, the module loader would know to search for
> "$MODNAME-btf" for each module which doesn't end with "-btf".
>

Hmm, could we just have a tristate CONFIG_DEBUG_INFO_BTF_EXTRA?
If set to y, the extra vars are builtin to vmlinux BTF and
modules, and if set to m, they reside in /sys/kernel/btf/vmlinux-btf-extra
courtesy of the vmlinux-btf-extra.ko module (or whatever naming
scheme makes sense). Looks like pahole already has an option to
store encoded BTF elsewhere:

--btf_encode_detached=FILENAME

...so maybe all we need is something like --btf_gen_var_only for
the case where we build the btf-extra module

pahole -J --btf_base vmlinux  --btf_gen_var_only 
--btf_encode_detached=vmlinux_btf_extra

?

That's still only 2-way split BTF (base vmlinux BTF
plus vmlinux variables); we'd only need the
three-way split for the case where modules use the
-extra approach too, and I'd wonder about the viability
of having an -extra BTF module for each module, especially
if space-saving is the goal.

Alan

  reply	other threads:[~2022-05-03 22:32 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
2022-05-03 17:29                   ` Stephen Brennan
2022-05-03 22:31                     ` Alan Maguire [this message]
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=alpine.LRH.2.23.451.2205032254390.10133@MyRouter \
    --to=alan.maguire@oracle.com \
    --cc=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=stephen@brennan.io \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox