BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>,
	andrii@kernel.org, jolsa@kernel.org,  acme@redhat.com,
	quentin@isovalent.com
Cc: mykolal@fb.com, ast@kernel.org, daniel@iogearbox.net,
	martin.lau@linux.dev,  song@kernel.org, yonghong.song@linux.dev,
	john.fastabend@gmail.com,  kpsingh@kernel.org, sdf@google.com,
	haoluo@google.com, houtao1@huawei.com,  bpf@vger.kernel.org,
	masahiroy@kernel.org, mcgrof@kernel.org, nathan@kernel.org
Subject: Re: [PATCH v5 bpf-next 1/9] libbpf: add btf__distill_base() creating split BTF with distilled base BTF
Date: Thu, 30 May 2024 12:58:43 -0700	[thread overview]
Message-ID: <3a133769ef18b35aaae9c46647af866b38b3b2f9.camel@gmail.com> (raw)
In-Reply-To: <20240528122408.3154936-2-alan.maguire@oracle.com>

On Tue, 2024-05-28 at 13:24 +0100, Alan Maguire wrote:
> To support more robust split BTF, adding supplemental context for the
> base BTF type ids that split BTF refers to is required.  Without such
> references, a simple shuffling of base BTF type ids (without any other
> significant change) invalidates the split BTF.  Here the attempt is made
> to store additional context to make split BTF more robust.
> 
> This context comes in the form of distilled base BTF providing minimal
> information (name and - in some cases - size) for base INTs, FLOATs,
> STRUCTs, UNIONs, ENUMs and ENUM64s along with modified split BTF that
> points at that base and contains any additional types needed (such as
> TYPEDEF, PTR and anonymous STRUCT/UNION declarations).  This
> information constitutes the minimal BTF representation needed to
> disambiguate or remove split BTF references to base BTF.  The rules
> are as follows:
> 
> - INT, FLOAT, FWD are recorded in full.
> - if a named base BTF STRUCT or UNION is referred to from split BTF, it
>   will be encoded as a zero-member sized STRUCT/UNION (preserving
>   size for later relocation checks).  Only base BTF STRUCT/UNIONs
>   that are either embedded in split BTF STRUCT/UNIONs or that have
>   multiple STRUCT/UNION instances of the same name will _need_ size
>   checks at relocation time, but as it is possible a different set of
>   types will be duplicates in the later to-be-resolved base BTF,
>   we preserve size information for all named STRUCT/UNIONs.
> - if an ENUM[64] is named, a ENUM forward representation (an ENUM
>   with no values) of the same size is used.
> - in all other cases, the type is added to the new split BTF.
> 
> Avoiding struct/union/enum/enum64 expansion is important to keep the
> distilled base BTF representation to a minimum size.
> 
> When successful, new representations of the distilled base BTF and new
> split BTF that refers to it are returned.  Both need to be freed by the
> caller.
> 
> So to take a simple example, with split BTF with a type referring
> to "struct sk_buff", we will generate distilled base BTF with a
> 0-member STRUCT sk_buff of the appropriate size, and the split BTF
> will refer to it instead.
> 
> Tools like pahole can utilize such split BTF to populate the .BTF
> section (split BTF) and an additional .BTF.base section.  Then
> when the split BTF is loaded, the distilled base BTF can be used
> to relocate split BTF to reference the current (and possibly changed)
> base BTF.
> 
> So for example if "struct sk_buff" was id 502 when the split BTF was
> originally generated,  we can use the distilled base BTF to see that
> id 502 refers to a "struct sk_buff" and replace instances of id 502
> with the current (relocated) base BTF sk_buff type id.
> 
> Distilled base BTF is small; when building a kernel with all modules
> using distilled base BTF as a test, overall module size grew by only
> 5.3Mb total across ~2700 modules.
> 
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---

I think this looks good, don't see any logical inconsistencies.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

  reply	other threads:[~2024-05-30 19:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 12:23 [PATCH v5 bpf-next 0/9] bpf: support resilient split BTF Alan Maguire
2024-05-28 12:24 ` [PATCH v5 bpf-next 1/9] libbpf: add btf__distill_base() creating split BTF with distilled base BTF Alan Maguire
2024-05-30 19:58   ` Eduard Zingerman [this message]
2024-05-28 12:24 ` [PATCH v5 bpf-next 2/9] selftests/bpf: test distilled base, split BTF generation Alan Maguire
2024-05-30 20:23   ` Eduard Zingerman
2024-05-28 12:24 ` [PATCH v5 bpf-next 3/9] libbpf: split BTF relocation Alan Maguire
2024-05-31  2:22   ` Eduard Zingerman
2024-05-31 15:38     ` Alan Maguire
2024-05-31 18:44       ` Andrii Nakryiko
2024-06-01  7:56       ` Eduard Zingerman
2024-06-02 13:47         ` Alan Maguire
2024-05-31 18:21   ` Andrii Nakryiko
2024-05-28 12:24 ` [PATCH v5 bpf-next 4/9] selftests/bpf: extend distilled BTF tests to cover " Alan Maguire
2024-05-31  2:23   ` Eduard Zingerman
2024-05-28 12:24 ` [PATCH v5 bpf-next 5/9] libbpf: make btf_parse_elf process .BTF.base transparently Alan Maguire
2024-05-31 18:57   ` Andrii Nakryiko
2024-06-01  8:04     ` Eduard Zingerman
2024-05-28 12:24 ` [PATCH v5 bpf-next 6/9] resolve_btfids: handle presence of .BTF.base section Alan Maguire
2024-05-28 12:24 ` [PATCH v5 bpf-next 7/9] module, bpf: store BTF base pointer in struct module Alan Maguire
2024-05-28 18:27   ` Luis Chamberlain
2024-05-28 12:24 ` [PATCH v5 bpf-next 8/9] libbpf,bpf: share BTF relocate-related code with kernel Alan Maguire
2024-05-31  9:34   ` Eduard Zingerman
2024-05-31 16:13     ` Alan Maguire
2024-05-31 19:04   ` Andrii Nakryiko
2024-06-01  1:59     ` Andrii Nakryiko
2024-06-02 13:42       ` Alan Maguire
2024-05-28 12:24 ` [PATCH v5 bpf-next 9/9] kbuild,bpf: add module-specific pahole flags for distilled base BTF Alan Maguire
2024-05-31 19:06   ` Andrii Nakryiko
2024-06-02 13:41     ` 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=3a133769ef18b35aaae9c46647af866b38b3b2f9.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=acme@redhat.com \
    --cc=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=houtao1@huawei.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mykolal@fb.com \
    --cc=nathan@kernel.org \
    --cc=quentin@isovalent.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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