[PATCH] thp: Disable THP if THP isn't supported by kernel

H.J. Lu hjl.tools@gmail.com
Wed Jul 22 21:36:01 GMT 2026


On Thu, Jul 23, 2026 at 2:17 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
> Hi HJ,
>
> > Since DL_MAP_DEFAULT_THP_PAGESIZE is defined for x86-64, THP control
> > is to set to madvise by default.  If THP is disabled in x86-64 kernel,
> > madvise (..., MADV_HUGEPAGE) returns -EINVAL to indicate that THP isn't
> > supported.  Add _dl_thp_madvise to disable THP in this case.  This
> > fixes BZ #34348.
>
> Are there enough calls in the loader that this is worthwhile?
>
> More importantly, does this actually work? I always get 0 result from madvise
> calls irrespectively of the madvise settings... Does it need a new kernel or is
> this target specific?

You need to run it under a kernel without THP support.  That is there is
no /sys/kernel/mm/transparent_hugepage/enabled.

> If we can get it to work, it could be useful in madvise_thp() since there are
> potentially millions madvise calls.
>
> Cheers,
> Wilco



-- 
H.J.


More information about the Libc-alpha mailing list