[PATCH] malloc: Enable THP always support on hugetlb tunable

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Jul 9 13:02:34 GMT 2025



On 09/07/25 08:56, William Hunt wrote:
> On 2025-07-08 19:05, Adhemerval Zanella Netto wrote:
>>> @@ -2011,6 +2013,11 @@ static inline void
>>>  madvise_thp (void *p, INTERNAL_SIZE_T size)
>>>  {
>>>  #ifdef MADV_HUGEPAGE
>>> +  /* Only use __madvise if the system is using 'madvise' mode.
>>> +     Otherwise the call is wasteful. */
>>> +  if (mp_.thp_mode != malloc_thp_mode_madvise)
>>> +    return;
>>> +
>> Does __glibc_likely make any difference here?
> 
> I did not find any significant performance gains due to mmap calls
> taking up enough time to make any differences immeasurable. Since
> THPs are not enabled this condition is likely true, so for readability 
> I can add the __glibc_likely if this helps, otherwise I will leave 
> the code as is.


I don't have a strong opinion, either way works fine.  This is not a
fast path, so it should not matter.



More information about the Libc-alpha mailing list