[PATCH v8 0/6] elf: THP-aware load segment alignment
H.J. Lu
hjl.tools@gmail.com
Fri Apr 10 04:19:48 GMT 2026
On Fri, Apr 10, 2026 at 11:58 AM WANG Rui <wangrui@loongson.cn> wrote:
>
> On Fri, Apr 10, 2026 at 11:35 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > 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.
>
> In earlier discussions, there was mention of memory pressure caused by
> THP, which is really a runtime system concern. When THP is not enabled
> by default on the system, I'm a bit unsure whether it's a good idea
> for a programer's decision to override the system default.
>
> Ideally, the executable itself would take care of hugepage-friendly
> alignment, the loader would make sure the mappings land on
> hugepage-aligned virtual addresses, and the final decision on whether
> to use huge pages would be left solely to THP. It has visibility into
> the system's dynamic state, and users would only need to deal with
> this single control point, making it relatively straightforward to
> turn it on or off.
>
What a property bit provides is flexibility.
--
H.J.
More information about the Libc-alpha
mailing list