Re: [PATCH v5 01/14] mm/khugepaged: remove READ_ONLY_THP_FOR_FS check

From: Andrew Morton

Date: Thu Apr 30 2026 - 11:08:40 EST


On Thu, 30 Apr 2026 10:37:52 -0400 Zi Yan <ziy@xxxxxxxxxx> wrote:

> + * MADV_COLLAPSE ignores shmem huge config, so do not check shmem
> > + *
> > + * TODO: once shmem always calls mapping_set_large_folios() on its
> > + * mapping, the shmem check can be removed.
> > + */
> > + VM_WARN_ON_ONCE(!is_shmem && !mapping_pmd_folio_support(mapping));
>
> sashiko asked:
> Is it possible for userspace to intentionally trigger this warning via
> madvise(MADV_COLLAPSE) on an unsupported read-only file? Although in
> a later commit, modified file_thp_enabled() will prevent this.
>
> Answer:
> It is possible when CONFIG_READ_ONLY_THP_FOR_FS is enabled, but it is
> unlikely a kernel will be shipped at this exact commit.

Yeah, let's not worry about minor bisection holes.