[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cilgdvjaihkdstabhvblpuz3xonuuxtaep462bdipaosbmp4sh@a3tsfzitaibb>
Date: Thu, 8 May 2025 20:22:12 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Rong Xu <xur@...gle.com>
Cc: tip-bot2 for Rong Xu <tip-bot2@...utronix.de>,
linux-tip-commits@...r.kernel.org, "Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [tip: objtool/core] objtool: Fix up st_info in COMDAT group
section
On Thu, May 08, 2025 at 05:45:18PM -0700, Rong Xu wrote:
> On Wed, May 7, 2025 at 4:22 PM Josh Poimboeuf <jpoimboe@...nel.org> wrote:
> >
> > On Wed, Apr 30, 2025 at 12:29:54PM +0000, tip-bot2 for Rong Xu wrote:
> > > The following commit has been merged into the objtool/core branch of tip:
> > >
> > > Commit-ID: 2cb291596e2c1837238bc322ae3545dacb99d584
> > > Gitweb: https://git.kernel.org/tip/2cb291596e2c1837238bc322ae3545dacb99d584
> > > Author: Rong Xu <xur@...gle.com>
> > > AuthorDate: Fri, 25 Apr 2025 13:05:41 -07:00
> > > Committer: Peter Zijlstra <peterz@...radead.org>
> > > CommitterDate: Wed, 30 Apr 2025 13:58:34 +02:00
> > >
> > > objtool: Fix up st_info in COMDAT group section
> > >
> > > When __elf_create_symbol creates a local symbol, it relocates the first
> > > global symbol upwards to make space. Subsequently, elf_update_symbol()
> > > is called to refresh the symbol table section. However, this isn't
> > > sufficient, as other sections might have the reference to the old
> > > symbol index, for instance, the sh_info field of an SHT_GROUP section.
> > >
> > > This patch updates the `sh_info` field when necessary. This field
> > > serves as the key for the COMDAT group. An incorrect key would prevent
> > > the linker's from deduplicating COMDAT symbols, leading to duplicate
> > > definitions in the final link.
> > >
> > > Signed-off-by: Rong Xu <xur@...gle.com>
> > > Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> > > Link: https://lkml.kernel.org/r/20250425200541.113015-1-xur@google.com
> >
> > Unfortunately this patch completely destroys performance when adding a
> > bunch of symbols. Which I'm doing in v2 of my klp-build patch set.
> The patch won't add symbols. Do you mean the updates take too much time
> when adding symbols?
Right. I was testing a new feature for generating livepatch modules. I
was using objtool to add thousands of local symbols to a binary with
-ffunction-sections and -fdata-sections, so it was calling that function
in a tight loop.
> It's probably true as we lookup the sections for every
> added symbols. I did not notice the compile time issues in my builds.
Yeah, I had an extreme test case :-)
> If this is a problem, it needs to be fixed.
> Thanks for working with v2!
> >
> > What was the use case for this? I don't remember seeing any COMDAT
> > groups in the kernel.
>
> In the PGO or AutoFDO builds, we used many COMDAT variables for counters
> and control variables. I think the compiler also puts the functions
> defined in header
> as COMDAT.
> The issue I encountered was objtool moved the variables for
> profile_filename and
> profile_version, but the comdat keys were not updated.
I see. Thanks for the explanation.
--
Josh
Powered by blists - more mailing lists