BPF List
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: andrii@kernel.org, ast@kernel.org, martin.lau@linux.dev,
	daniel@iogearbox.net
Cc: song@kernel.org, yhs@fb.com, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@google.com, haoluo@google.com,
	jolsa@kernel.org, masahiroy@kernel.org, michal.lkml@markovi.net,
	ndesaulniers@google.com, bpf@vger.kernel.org,
	Alan Maguire <alan.maguire@oracle.com>
Subject: [RFC bpf-next 0/2] bpf: standalone BTF support for modules
Date: Fri,  4 Nov 2022 15:58:05 +0000	[thread overview]
Message-ID: <1667577487-9162-1-git-send-email-alan.maguire@oracle.com> (raw)

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


             reply	other threads:[~2022-11-04 15:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 15:58 Alan Maguire [this message]
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

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=1667577487-9162-1-git-send-email-alan.maguire@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=ndesaulniers@google.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --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