From: Jiri Olsa <jolsa@redhat.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 1/2] libbpf: accommodate DWARF/compiler bug with duplicated structs
Date: Wed, 24 Nov 2021 21:21:34 +0100 [thread overview]
Message-ID: <YZ6ezpVG8jgLV12k@krava> (raw)
In-Reply-To: <CAEf4BzZ5DXdKAVD15r4tViH8neaKV4Pq82P6bWKRT2SAt7Jd9Q@mail.gmail.com>
On Wed, Nov 24, 2021 at 11:20:42AM -0800, Andrii Nakryiko wrote:
> On Wed, Nov 24, 2021 at 7:02 AM Jiri Olsa <jolsa@redhat.com> wrote:
> >
> > On Wed, Nov 24, 2021 at 12:39:00PM +0100, Jiri Olsa wrote:
> > > On Thu, Nov 18, 2021 at 02:49:35PM -0800, Andrii Nakryiko wrote:
> > > > On Thu, Nov 18, 2021 at 6:27 AM Jiri Olsa <jolsa@redhat.com> wrote:
> > > > >
> > > > > On Wed, Nov 17, 2021 at 11:42:58AM -0800, Andrii Nakryiko wrote:
> > > > > > On Wed, Nov 17, 2021 at 11:41 AM Andrii Nakryiko <andrii@kernel.org> wrote:
> > > > > > >
> > > > > > > According to [0], compilers sometimes might produce duplicate DWARF
> > > > > > > definitions for exactly the same struct/union within the same
> > > > > > > compilation unit (CU). We've had similar issues with identical arrays
> > > > > > > and handled them with a similar workaround in 6b6e6b1d09aa ("libbpf:
> > > > > > > Accomodate DWARF/compiler bug with duplicated identical arrays"). Do the
> > > > > > > same for struct/union by ensuring that two structs/unions are exactly
> > > > > > > the same, down to the integer values of field referenced type IDs.
> > > > > >
> > > > > > Jiri, can you please try this in your setup and see if that handles
> > > > > > all situations or there are more complicated ones still. We'll need a
> > > > > > test for more complicated ones in that case :( Thanks.
> > > > >
> > > > > it seems to help largely, but I still see few modules (67 out of 780)
> > > > > that keep 'struct module' for some reason.. their struct module looks
> > > > > completely the same as is in vmlinux
> > > >
> > > > Curious, what's the size of all the module BTFs now?
> > >
> > > sorry for delay, I was waiting for s390x server
> > >
> > > so with 'current' fedora kernel rawhide I'm getting slightly different
> > > total size number than before, so something has changed after the merge
> > > window..
> > >
> > > however the increase with BTF enabled in modules is now from 16M to 18M,
> > > so the BTF data adds just about 2M, which I think we can live with
> > >
>
> 16MB for vmlinux BTF is quite a lot. Is it a allmodyesconfig or something?
looks like my english betrayed me again.. sry ;-)
size of all modules without BTF is 16M,
size of all modules with BTF is 18M,
so it's overall 2M increase
also note that each module is compressed with xz
jirka
>
> > > > And yes, please
> > > > try to narrow down what is causing the bloat this time. I think this
> > >
> > > I'm on it
> >
> > I'm seeing vmlinux BTF having just FWD record for sctp_mib struct,
> > while the kernel module has the full definition
> >
> > kernel:
> >
> > [2798] STRUCT 'netns_sctp' size=296 vlen=46
> > 'sctp_statistics' type_id=2800 bits_offset=0
> >
> > [2799] FWD 'sctp_mib' fwd_kind=struct
> > [2800] PTR '(anon)' type_id=2799
> >
> >
> > module before dedup:
> >
> > [78928] STRUCT 'netns_sctp' size=296 vlen=46
> > 'sctp_statistics' type_id=78930 bits_offset=0
> >
> > [78929] STRUCT 'sctp_mib' size=272 vlen=1
> > 'mibs' type_id=80518 bits_offset=0
> > [78930] PTR '(anon)' type_id=78929
> >
> >
> > this field is referenced from within 'struct module' so it won't
> > match its kernel version and as a result extra 'struct module'
> > stays in the module's BTF
> >
>
> Yeah, not much we could do about that short of just blindly matching
> FWD to STRUCT/UNION/ENUM by name, which sounds bad to me, I avoided
> doing that in BTF dedup algorithm. We only resolve FWD to
> STRUCT/UNION/ENUM when we have some containing struct with a field
> that points to FWD and (in another instance of the containing struct)
> to STRUCT/UNION/ENUM. That way we have sort of a proof that we are
> resolving the right FWD. While in this case it would be a blind guess
> based on name alone.
>
> > I'll need to check debuginfo/pahole if that FWD is correct, but
> > I guess it's normal that some structs might end up unwinded only
> > in modules and not necessarily in vmlinux
>
> It can happen, yes. If that's a very common case, ideally we should
> make sure that modules keep FWD or that vmlinux BTF does have a full
> struct instead of FWD.
>
>
> >
> > jirka
> >
>
next prev parent reply other threads:[~2021-11-24 20:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 19:41 [PATCH bpf-next 1/2] libbpf: accommodate DWARF/compiler bug with duplicated structs Andrii Nakryiko
2021-11-17 19:41 ` [PATCH bpf-next 2/2] selftests/bpf: add btf_dedup case with duplicated structs within CU Andrii Nakryiko
2021-11-17 19:42 ` [PATCH bpf-next 1/2] libbpf: accommodate DWARF/compiler bug with duplicated structs Andrii Nakryiko
2021-11-18 14:27 ` Jiri Olsa
2021-11-18 22:49 ` Andrii Nakryiko
2021-11-24 11:38 ` Jiri Olsa
2021-11-24 15:02 ` Jiri Olsa
2021-11-24 19:20 ` Andrii Nakryiko
2021-11-24 20:21 ` Jiri Olsa [this message]
2021-11-24 20:42 ` Andrii Nakryiko
2021-11-19 16:10 ` patchwork-bot+netdevbpf
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=YZ6ezpVG8jgLV12k@krava \
--to=jolsa@redhat.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=kernel-team@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