From: Jiri Olsa <olsajiri@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Sami Tolvanen <samitolvanen@google.com>,
Jiri Olsa <olsajiri@gmail.com>,
dwarves@vger.kernel.org, acme@kernel.org,
yonghong.song@linux.dev, ast@kernel.org, andrii@kernel.org,
bpf@vger.kernel.org, daniel@iogearbox.net, song@kernel.org,
eddyz87@gmail.com, stephen.s.brennan@oracle.com,
laura.nao@collabora.com, ubizjak@gmail.com,
xiyou.wangcong@gmail.com
Subject: Re: [PATCH dwarves] btf_encoder: Filter out __gendwarfksyms_ptr_
Date: Thu, 20 Mar 2025 12:59:09 +0100 [thread overview]
Message-ID: <Z9wDDY4ET94ruTSh@krava> (raw)
In-Reply-To: <45881882-46d2-43ca-b833-439363926c87@oracle.com>
On Thu, Mar 20, 2025 at 09:54:21AM +0000, Alan Maguire wrote:
> On 18/03/2025 16:14, Sami Tolvanen wrote:
> > Hi Jiri,
> >
> > On Tue, Mar 18, 2025 at 9:52 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >>
> >> On Mon, Mar 17, 2025 at 10:24:24PM +0000, Sami Tolvanen wrote:
> >>> With CONFIG_GENDWARFKSYMS, __gendwarfksyms_ptr_<symbol>
> >>> variables are added to the kernel in EXPORT_SYMBOL() to ensure
> >>> DWARF type information is available for exported symbols in the
> >>> TUs where they're actually exported. These symbols are dropped
> >>> when linking vmlinux, but dangling references to them remain
> >>> in DWARF, which results in thousands of 0 address variables
> >>> that pahole needs to validate (since commit 9810758003ce
> >>> ("btf_encoder: Verify 0 address DWARF variables are in ELF
> >>> section")).
> >>>
> >>> Filter out symbols with the __gendwarfksyms_ptr_ name prefix in
> >>> filter_variable_name() instead of calling variable_in_sec()
> >>> for all of them. This reduces the time it takes to process
> >>> .tmp_vmlinux1 by ~77% on my test system:
> >>>
> >>> Before: 35.775 +- 0.121 seconds time elapsed ( +- 0.34% )
> >>> After: 8.3516 +- 0.0407 seconds time elapsed ( +- 0.49% )
> >>
> >> makes sense to me, I just can't reproduce the speedup
> >> could you please share your .config?
> >
> > Sure, here's the config I used to repro this:
> >
> > https://gist.github.com/samitolvanen/dca66a1a779861be27579f88c9b6ba5d
> >
> > This is essentially x86_64 defconfig with GENDWARFKSYMS and
> > DEBUG_INFO_BTF both enabled. When building this config with gcc, we
> > end up with 0 address __gendwarfksyms_ptr variables in DWARF:
> >
> > ...
> > 0x0001b5c6: DW_TAG_variable
> > DW_AT_name ("__gendwarfksyms_ptr_system_state")
> > DW_AT_decl_file ("../init/main.c")
> > DW_AT_decl_line (129)
> > DW_AT_decl_column (1)
> > DW_AT_type (0x0001b5dc "system_states *")
> > DW_AT_location (DW_OP_addr 0x0)
> > ...
> >
> > Note that this doesn't seem to happen when building with Clang.
> >
> > Before commit 9810758003ce this resulted in pahole thinking all these
> > variables are in the .data..percpu section, which resulted in
> > btf_datasec_check_meta() failing with "Invalid offset" during boot.
> > pahole/next doesn't have this issue, but validating the 0 address
> > variables is unfortunately a bit slow when we have a lot of them.
> >
>
> Thanks for the fix Sami! I've tested it at my end and can reproduce the
> longer time for BTF encoding on x86_64 prior to the fix and its
> resolution. Let's wait a bit longer before landing it to see if anyone
> else gets a chance to test/ack it, but I think we should probably also add a
>
> Fixes: 9810758003ce9f ("btf_encoder: Verify 0 address DWARF variables
> are in ELF section")
+1
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
>
> (no need to resend for this; I can add it when committing it)
>
> I'm thinking we should also try and incorporate some performance tests
> for vmlinux BTF encoding into the tests subdirectory to better catch
> issues like this; perhaps the CI can baseline encoding performance on
> the next branch versus the branch that has the changes..
>
> Thanks again!
>
> Alan
> > Sami
>
next prev parent reply other threads:[~2025-03-20 11:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 22:24 [PATCH dwarves] btf_encoder: Filter out __gendwarfksyms_ptr_ Sami Tolvanen
2025-03-18 9:52 ` Jiri Olsa
2025-03-18 16:14 ` Sami Tolvanen
2025-03-20 9:54 ` Alan Maguire
2025-03-20 11:59 ` Jiri Olsa [this message]
2025-03-24 8:16 ` 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=Z9wDDY4ET94ruTSh@krava \
--to=olsajiri@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dwarves@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=laura.nao@collabora.com \
--cc=samitolvanen@google.com \
--cc=song@kernel.org \
--cc=stephen.s.brennan@oracle.com \
--cc=ubizjak@gmail.com \
--cc=xiyou.wangcong@gmail.com \
--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 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.