[PATCH v8 0/6] elf: THP-aware load segment alignment

H.J. Lu hjl.tools@gmail.com
Fri Apr 10 03:26:36 GMT 2026


On Fri, Apr 10, 2026 at 10:57 AM WANG Rui <wangrui@loongson.cn> wrote:
>
> On Fri, Apr 10, 2026 at 9:26 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Fri, Apr 10, 2026 at 7:33 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
> > >
> > > Hi HJ,
> > >
> > > > Why a tunable at all?  Users may not set it.
> > >
> > > If it is already the default, users never need to set it. It makes benchmarking
> > > simpler at a cost that is ~10000x lower than checking the huge page size.
> > >
> >
> > Even if THP isn't enabled by default, like for 32-bit mode.  We may still
> > want to enable THP on specific 32-bit applications.   A property bit provides
> > such flexibility without requiring the user to set a tunable at run-time.
>
> Do we really need a flag in the executable file to hint the loader to
> cooperate with THP? If we already have the ability to modify the
> executable, why not just make the LOAD segmengts hugepage-aligned in
> the first place?
>
> As you can see, this optimization is currently opt-in on most arches
> rather than enabled by default. I see the tunable as more of a
> transitional mechanism, it simply gives users a way to turn the opt on
> and on arches where it is enbled by default, it can also be used to
> turn it off.
>

This all or nothing approach is my main concern.  A programmer
may want to enable THP on an application even if THP isn't enabled
by default.    The overhead of checking a bit in the l_1_needed field
is minimum.

-- 
H.J.


More information about the Libc-alpha mailing list