Re: [PATCH v1 05/10] mm/huge_memory: remove READ_ONLY_THP_FOR_FS from file_thp_enabled()

Andres Freund
2026-04-10T15:38:57Z

Hi,

On 2026-04-10 11:18:24 -0400, Zi Yan wrote:
> On 10 Apr 2026, at 11:06, Andres Freund wrote:
> > 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?
>
> Yes, assuming your file system supports PMD THPs.
>
> Based on[1], ext4 and xfs have the support, btrfs supports large folio but
> not up to PMD order. I have not checked other FSes supporting large folio[2].

I personally only care about ext4 and xfs, so this is awesome.

Thanks,

Andres