All of lore.kernel.org
 help / color / mirror / Atom feed
* Question: missing vmlinux BTF variable declarations
@ 2022-03-09 23:20 Stephen Brennan
  2022-03-14  7:09 ` Shung-Hsi Yu
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Brennan @ 2022-03-09 23:20 UTC (permalink / raw)
  To: bpf; +Cc: Omar Sandoval, Arnaldo Carvalho de Melo

Hello everyone,

I've been recently learning about BTF with a keen interest in using it
as a fallback source of debug information. On the face of it, Linux
kernels these days have a lot of introspection information. BTF provides
information about types. kallsyms provides information about symbol
locations. ORC allows us to reliably unwind stack traces. So together,
these could enable a debugger (either postmortem, or live) to do a lot
without needing to read the (very large) DWARF debuginfo files. For
example, we could format backtraces with function names, we could
pretty-print global variables and data structures, etc. This is nice
given that depending on your distro, it might be tough to get debuginfo,
and it is quite large to download or install.

As I've worked toward this goal, I discovered that while the
BTF_KIND_VAR exists [1], the BTF included in the core kernel only has
declarations for percpu variables. This makes BTF much less useful for
this (admittedly odd) use case. Without a way to bind a name found in
kallsyms to its type, we can't interpret global variables. It looks like
the restriction for percpu-only variables is baked into the pahole BTF
encoder [2].

[1]: https://www.kernel.org/doc/html/latest/bpf/btf.html#btf-kind-var
[2]: https://github.com/acmel/dwarves/blob/master/btf_encoder.c

I wonder what the BPF / BTF community's thoughts are on including more
of these global variable declarations? Perhaps behind a
CONFIG_DEBUG_INFO_BTF_ALL, like how kallsyms does it? I'm aware that
each declaration costs at least 16 bytes of BTF records, plus the
strings and any necessary type data. The string cost could be mitigated
by allowing "name_off" to refer to the kallsyms offset for variable or
function declaration. But the additional records could cost around 1MiB
for common distribution configurations.

I know this isn't the designed use case for BTF, but I think it's very
exciting.

Thanks for your attention!
Stephen

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-05-10  0:10 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-05-10  0:10                       ` Andrii Nakryiko

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.