[PATCH 2/2] LoongArch64: Align large code segments to 32MB for THP

Florian Weimer fweimer@redhat.com
Tue Feb 24 09:30:14 GMT 2026


* WANG Rui:

> +#ifdef __LP64__
> +  /* On LoongArch64, using 16K normal pages means we get 32M PMD huge
> +   * pages. So, if we align code segments of 32M or more to 32M address,
> +   * it really helps with THP eligibility. */
> +  if (__glibc_likely (GLRO(dl_pagesize) == 16384)
> +      && c->mapstart == 0 && c->mapoff == 0
> +      && (c->mapend - c->mapstart) >= 32 * 1024 * 1024
> +      && mapalign < 32 * 1024 * 1024 && c->prot & PROT_EXEC)
> +    mapalign = 32 * 1024 * 1024;
> +#endif

We don't use leading * for comments.

The size check should not be for the entire mapping, but for individual
load segments.  Even if the mapping is (say) 40 MiB, the optimization
won't work if there's a 30 MiB code mapping and a 10 MiB data mapping.

Thanks,
Florian



More information about the Libc-alpha mailing list