[PATCH] nptl: Disable THP on thread stack if it incurs in large RSS usage
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Wed May 3 12:42:59 GMT 2023
Hi Adhemerval,
> +static __always_inline int
> +advise_thp (void *mem, size_t size, char *guard)
> +{
> + enum malloc_thp_mode_t thpmode = __malloc_thp_mode ();
> + if (thpmode != malloc_thp_mode_always)
> + return 0;
> +
> + unsigned long int thpsize = __malloc_default_thp_pagesize ();
> + if (PTR_ALIGN_DOWN (mem, thpsize) != PTR_ALIGN_DOWN (guard, thpsize))
> + return 0;
> +
> + return __madvise (mem, size, MADV_NOHUGEPAGE);
> +}
This still doesn't make sense since if _STACK_GROWS_DOWN, mem == guard, so
this will always execute the madvise. As I mentioned, I couldn't find evidence that
the claimed scenario of a huge page allocated, written to and then split due to the
mprotect exists.
So the real issue is that the current stack allocation code randomly (based on
alignment from previous mmap calls) uses huge pages even for small stacks.
Cheers,
Wilco
More information about the Libc-alpha
mailing list