All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC bpf-next 0/2] bpf: standalone BTF support for modules
@ 2022-11-04 15:58 Alan Maguire
  2022-11-04 15:58 ` [RFC bpf-next 1/2] bpf: support standalone BTF in modules Alan Maguire
  2022-11-04 15:58 ` [RFC bpf-next 2/2] bpf: allow opt-out from using split BTF for modules Alan Maguire
  0 siblings, 2 replies; 8+ messages in thread
From: Alan Maguire @ 2022-11-04 15:58 UTC (permalink / raw)
  To: andrii, ast, martin.lau, daniel
  Cc: song, yhs, john.fastabend, kpsingh, sdf, haoluo, jolsa,
	masahiroy, michal.lkml, ndesaulniers, bpf, Alan Maguire

Split BPF Type Format (BTF) information for modules provides a
major space saving, but if a module is built less frequently
than the underlying kernel which it bases its BTF upon, the
associated references become invalid and either the module
will fail to load (CONFIG_BTF_ALLOW_MODULE_MISMATCH=n) or
it will load without BTF available in /sys/kernel/btf
(CONFIG_BTF_ALLOW_MODULE_MISMATCH=y).  This problem was
first raised in [1], so there is more discussion there.

This series represents a simple proof-of-concept for handling
standalone BTF - where the BTF for the module is not
generated relative to base vmlinux BTF.  The core problem
with this is that all the tooling presumes split BTF for
modules, so on module BTF load, we rework the BTF to appear
as split BTF.  It does not change in form - it still is
only self-referential - but is compatible with split BTF
interpretation.

Building a module with standalone BTF is done via

 make BTF_BASE= M=path/2/module

The detection of standalone BTF on module load is likely much
too simplistic - we simply fall back to assuming standalone
BTF if the BTF associated with the module appears to be invalid.
However this approach seems to work well in practice.

Tests etc are needed but wanted to get the proof-of-concept
out for others to provide feedback early.

[1] https://lore.kernel.org/bpf/YfK18x%2FXrYL4Vw8o@syu-laptop/

Alan Maguire (2):
  bpf: support standalone BTF in modules
  bpf: allow opt-out from using split BTF for modules

 kernel/bpf/btf.c          | 132 ++++++++++++++++++++++++++++++++++++++++++++++
 scripts/Makefile.modfinal |   4 +-
 2 files changed, 135 insertions(+), 1 deletion(-)

-- 
1.8.3.1


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

end of thread, other threads:[~2022-11-22 18:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 15:58 [RFC bpf-next 0/2] bpf: standalone BTF support for modules Alan Maguire
2022-11-04 15:58 ` [RFC bpf-next 1/2] bpf: support standalone BTF in modules Alan Maguire
2022-11-05 22:54   ` Alexei Starovoitov
2022-11-07 16:37     ` Alan Maguire
2022-11-09 22:43       ` Andrii Nakryiko
2022-11-22 17:36         ` Alan Maguire
2022-11-22 18:12           ` Andrii Nakryiko
2022-11-04 15:58 ` [RFC bpf-next 2/2] bpf: allow opt-out from using split BTF for modules Alan Maguire

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.