Re: [PATCH v1 05/10] mm/huge_memory: remove READ_ONLY_THP_FOR_FS from file_thp_enabled()
From: Jan Kara
Date: Mon Apr 13 2026 - 04:47:38 EST
On Fri 10-04-26 11:06:23, Andres Freund wrote:
> Hi,
>
> On 2026-03-26 21:42:50 -0400, Zi Yan wrote:
> > Replace it with a check on the max folio order of the file's address space
> > mapping, making sure PMD_ORDER is supported.
>
> Question from a user space developer (who learned of this via LWN [1]):
>
> Right now MADV_COlLAPSE on file mappings appears to only only work with
> CONFIG_READ_ONLY_THP_FOR_FS.
>
> That's pretty sad, because I see quite consistent gains (~15%) from doing
> madvise(MADV_COLLAPSE) on e.g. postgres' .text - but because
> CONFIG_READ_ONLY_THP_FOR_FS is not enabled default (or at least not commonly,
> I think?) in distro kernels, it never quite seemed worth the fiddliness.
>
>
> Do I understand correctly that by replacing the check here (and the
> predecessor commits), madvise(MADV_COLLAPSE) on file mappings might actually
> start working in more situations on typical distro kernels?
FWIW we soon might be creating PMD sized folios for executable VMAs by
default [1] (at least for archs with 4k page size). So there'd be no need
for explicit MADV_COLLAPSE to get the gain.
Honza
[1] https://lore.kernel.org/all/20260402181326.3107102-3-usama.arif@xxxxxxxxx/
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR