[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87eczm6ckn.fsf@oracle.com>
Date: Mon, 24 Feb 2025 17:24:40 -0800
From: Stephen Brennan <stephen.s.brennan@...cle.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>,
Masahiro Yamada
<masahiroy@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>, Andrii Nakryiko <andrii@...nel.org>,
Nicolas Schier <nicolas@...sle.eu>, Kees Cook <kees@...nel.org>,
KP Singh
<kpsingh@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Sami
Tolvanen <samitolvanen@...gle.com>,
Eduard Zingerman <eddyz87@...il.com>, linux-arch@...r.kernel.org,
Stanislav Fomichev <sdf@...ichev.me>,
Kent
Overstreet <kent.overstreet@...ux.dev>,
Pasha Tatashin
<pasha.tatashin@...een.com>,
Jiri Olsa <jolsa@...nel.org>,
John Fastabend
<john.fastabend@...il.com>,
Jann Horn <jannh@...gle.com>, Ard Biesheuvel
<ardb@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, Hao Luo
<haoluo@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kbuild@...r.kernel.org, Daniel Borkmann <daniel@...earbox.net>,
Nathan Chancellor <nathan@...nel.org>, linux-debuggers@...r.kernel.org,
Alexei Starovoitov <ast@...nel.org>, Song Liu <song@...nel.org>,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH 1/2] kallsyms: output rodata to ".kallsyms_rodata"
Andrii Nakryiko <andrii.nakryiko@...il.com> writes:
> On Sat, Feb 15, 2025 at 6:21 AM Masahiro Yamada <masahiroy@...nel.org> wrote:
>>
>> On Fri, Feb 7, 2025 at 10:21 AM Stephen Brennan
>> <stephen.s.brennan@...cle.com> wrote:
>> >
>> > When vmlinux is linked, the rodata from kallsyms is placed arbitrarily
>> > within the .rodata section. The linking process is repeated several
>> > times, since the kallsyms data size changes, which shifts symbols,
>> > requiring re-generating the data and re-linking.
>> >
>> > BTF is generated during the first link only. For variables, BTF includes
>> > a BTF_K_DATASEC for each data section that may contain a variable, which
>> > includes the variable's name, type, and offset within the data section.
>> > Because the size of kallsyms data changes during later links, the
>> > offsets of variables placed after it in .rodata will change. This means
>> > that BTF_K_DATASEC information for those variables becomes inaccurate.
>> >
>> > This is not currently a problem, because BTF currently only generates
>> > variable data for percpu variables. However, the next commit will add
>> > support for generating BTF for all global variables, including for the
>> > .rodata section.
>> >
>> > We could re-generate BTF each time vmlinux is linked, but this is quite
>> > expensive, and should be avoided at all costs. Further as each chunk of
>> > data (BTF and kallsyms) are re-generated, there's no guarantee that
>> > their sizes will converge anyway.
>> >
>> > Instead, we can take advantage of the fact that BTF only cares to store
>> > the offset of variables from the start of their section. Therefore, so
>> > long as the kallsyms data is stored last in the .rodata section, no
>> > offsets will be affected. Adjust kallsyms to output to .rodata.kallsyms,
>> > and update the linker script to include this at the end of .rodata.
>> >
>> > Signed-off-by: Stephen Brennan <stephen.s.brennan@...cle.com>
>> > ---
>>
>> I am fine if this is helpful for BTF.
>
> This seems like a useful change all by itself even while the main
> feature of this patch set is still being developed and reviewed.
> Should we land just this .kallsyms_rodata change?
I would be happy to see it merged now.
I don't think it would help anything other than BTF, because most other
things (e.g. kallsyms) refer to symbols via an absolute address. Using
the section offset seems pretty uncommon.
But it still is a nice cleanup anyway.
Thanks,
Stephen
Powered by blists - more mailing lists