Re: [PATCH 0/4] arm64/mm: contpte-sized exec folios for 16K and 64K pages

From: WANG Rui

Date: Wed Mar 18 2026 - 07:47:34 EST


> Thanks for running these! Just wanted to check what is the base page size
> of this experiment?

base page size: 4K

> Yeah I think introducing Kconfig might be an option.

I wonder if it would make sense for exec_folio_order() to vary the
order based on the code size, instead of always returning a fixed
value for a given architecture and base page size.

For example, on AArch64 with 4K base pages, in the load_elf_binary()
case: if exec_folio_order() only ever returns cont-PTE (64K), we may
miss the opportunity to use PMD mappings. On the other hand, if it
always returns PMD (2M), then for binaries smaller than 2M we end up
reducing ASLR entropy.

Maybe something along these lines would work better:

unsigned int exec_folio_order(size_t code_size)
{
#if PAGE_SIZE == 4096
if (code_size >= PMD_SIZE)
return ilog2(SZ_2M >> PAGE_SHIFT);
else if (code_size >= SZ_64K)
return ilog2(SZ_64K >> PAGE_SHIFT);
else
return 0;
#elif PAGE_SIZE == 16384
...
#elif PAGE_SIZE == ...
/* let the arch cap the max order here, rather
than hard-coding it at the use sites */
#endif
}

Thanks,
Rui